Accueil – Le CFO masqué › Forums › Power Query › Décumul de montant à partir du total et périodes début/fin
- Ce sujet contient 1 réponse, 1 participant et a été mis à jour pour la dernière fois par
chikletch, le il y a 5 années et 4 mois.
-
AuteurMessages
-
26 octobre 2019 à 9 h 40 min #58774
chikletch
ParticipantBonjour, désolé, je post en anglais car je viens de poster sur le forum de MS … mais les réponses peuvent être en français sans aucun problème. Merci pour le coup de main, et félicitation aux membres de cette communauté.
Hi,
I am a debutant in PowerQuery, and I search to have “decumulation” or periodical amounts from a cumulative amount.My use case is the following: I have one table with Item Description, Start Date, End Date and an amount for this duration. I need to obtain a table with the amount for each period (each day between Start Date and End Date, for example).
Table ITEMS:
Item StartDate EndDate TotAmnt
Fsdfsfssf 01/01/2019 01/01/2022 43454,09
Vfvsfsfgsfgs 13/02/2020 19/06/2022 984334,43
…….With SQL statement, it’s easy.
I create a table with all the periods I need and I obtain what I want with this statement.Table CALENDAR:
Period
01/01/2018
01/02/2018
01/03/2018
……..SELECT ITEMS.Item, Period AS CALENDAR.Period, PeriodAmount AS ITEMS.TotAmnt/(DateDiff(ITEMS.StartDate, ITEMS.EndDate))
FROM ITEMS, CALENDAR
WHERE (CALENDAR.Period >= ITEMS.StartDate AND CALENDAR.Period < ITEMS.EndDate)How can I do that with PowerQuery and Langage M, using data/table from my current Excel Sheet?
I have seen how to connect me to twos tables in Excel which are basically my ITEMS and CALENDAR tables.
Then, I tried to use the method Table.SelectRows and similar criterias of my SQL Statement: Calendar.Period >= ITEMS.Start, etc… but it doesn’t work… the method expects a logical result and not a function one.
I try to use also methods from List… without success.I am thinking writing some Loops, but I don’t have already understood correctly how the “each” operator works.
Somebody can give me some orientations and tips ?
I imagine that this need to cumulate or “decumulate” (or uncumulate ?) amounts are a recurrent use case for PowerQuery developpers.Thanks for any help.
Chikus26 octobre 2019 à 18 h 27 min #58783chikletch
ParticipantUne réponse a été postée sur TechNet, je la partage à toute fin utile.
En fait, la méthode proposée (et qui marche très bien) est :
* créer une liste de toutes les dates comprises entre la date de début et la date de fin ;
* compter le nombre de valeur de cette liste (dénominateur) ;
* diviser le montant total par ce dénominateur ;
* Déployer (Déplier) la liste et j’obtiens la table attendue.Sympa PowerQuery et le Langage M … plus besoin de SQL, etc… et tout dans Excel
-
AuteurMessages
- Vous devez être connecté pour répondre à ce sujet.