Forum Discussion
dax formula help (Distribution) v2
Hello v-alq-msft,
so there is no way to achieve what i want to do in DAX ?
I wanted to do it in desktop because i want to be able to display graphs with the distribution on power BI.
At the beginning i did it with SUMIFS in excel, and 3 columns in an excel sheet, then i was loading the results in a query. But as i wanted to automate everything in a query directly to export it on power BI i faced a problem of circular columns. Then i saw this solution in dax.
I can try to share my excel file, to show you what i did with my sumifs, but so far was not able to translate this solution in power query directly.
why can't i post
- Anonymous6 years agoNot applicable
Following my previous message, please find attached the code of my excel file :
I have 3 queries :
- one to load my stock table :
let Source = Excel.CurrentWorkbook(){[Name="Tableau3"]}[Content], #"Index ajouté" = Table.AddIndexColumn(Source, "Index", 1, 1), #"Type modifié" = Table.TransformColumnTypes(#"Index ajouté",{{"Product", type text}, {"Week", Int64.Type}, {"Stock Quantity", Int64.Type}}) in #"Type modifié"- One table with my order requests
let Source = Excel.CurrentWorkbook(){[Name="Tableau2"]}[Content], #"Type modifié" = Table.TransformColumnTypes(Source,{{"Product Type", type text}, {"Requested Week", Int64.Type}, {"Requested Qty", Int64.Type}}), #"Index ajouté" = Table.AddIndexColumn(#"Type modifié", "Index", 1, 1) in #"Index ajouté"- On table to do my allocation
let Source = #"Orders request", #"Requêtes fusionnées" = Table.NestedJoin(Source, {"Product Type"}, #"Product stock", {"Product"}, "Product stock", JoinKind.LeftOuter), #"Product stock développé" = Table.ExpandTableColumn(#"Requêtes fusionnées", "Product stock", {"Week", "Stock Quantity", "Index"}, {"Product stock.Week", "Product stock.Stock Quantity", "Product stock.Index"}) in #"Product stock développé"The columns in grey are added after running my last query and are the ones doing the allocation. Howver i'm afraid i'm using only sumf ifs to do so as i was mentionning before.
Here the formulas :
Remaining Stock to Allocate : =[@[Requested Qty]]-SOMME.SI.ENS($J$1:J1;$D$1:D1;[@Index]) Remaining stock to distribute : =[@[Product stock.Stock Quantity]]-SOMME.SI.ENS($J$1:J1;$G$1:G1;[@[Product stock.Index]]) Allocated Qty : =MIN([@[Remaining Stock to Allocate]];[@[Remaining stock to distribute]])I would have joined the excel file but apparently i can't, i hope what i did in the excel file is clear for you.
Any remark on how to do that on power query would be so helpful 🙂
Thanks a lot
- Anonymous6 years agoNot applicable
Hello,
Any ideas, anyone ? I'm stuck behind a wall 😥
Best regards