Forum Discussion
Using VAR "calculated measure" INSIDE CALCULATE perhaps? Allocation from Tier to Tier
- Anonymous1 year ago
Hi JustDavid ,
Thanks again for your follow-up and for confirming that your sample data mirrors your actual setup.
Here is the updated version which works without needing any ReplaceValue steps:
let Source = Table.NestedJoin(wfTier1, {"From", "PBR Period"}, factTable, {"Business Unit", "FY_Period"}, "factTable", JoinKind.LeftOuter), #"Expanded factTable" = Table.ExpandTableColumn(Source, "factTable", {"Amount"}, {"Amount"}), #"Removed Duplicates" = Table.Distinct(#"Expanded factTable", {"From", "To", "PBR Period", "Amount"}), #"Added AllocValue" = Table.AddColumn(#"Removed Duplicates", "AllocValue", each [Amount] * [Alloc]), #"Grouped Rows" = Table.Group(#"Added AllocValue", {"To", "PBR Period"}, {{"TotalAllocated", each List.Sum([AllocValue]), type number}}), #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each true), #"Removed Duplicates1" = Table.Distinct(#"Filtered Rows", {"To"}) in #"Removed Duplicates1"
The key change was ensuring the join happens on both From and PBR Period columns, which properly aligns the allocation logic period-wise. Additionally, removing duplicates based on From, To, PBR Period, and Amount prevents repeated cost entries from inflating the totals - which was the main cause of the earlier over-allocated results. So with these changes, the Tier 1 allocations now correctly match expectations without needing any manual adjustments.Thanks again for your patience while this was being worked.
Hope this helps, and please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly.
Thank you.Please find attached .pbix for reference.
Hi JustDavid ,
Thanks again for your follow-up and for confirming that your sample data mirrors your actual setup.
Here is the updated version which works without needing any ReplaceValue steps:
let
Source = Table.NestedJoin(wfTier1, {"From", "PBR Period"}, factTable, {"Business Unit", "FY_Period"}, "factTable", JoinKind.LeftOuter),
#"Expanded factTable" = Table.ExpandTableColumn(Source, "factTable", {"Amount"}, {"Amount"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded factTable", {"From", "To", "PBR Period", "Amount"}),
#"Added AllocValue" = Table.AddColumn(#"Removed Duplicates", "AllocValue", each [Amount] * [Alloc]),
#"Grouped Rows" = Table.Group(#"Added AllocValue", {"To", "PBR Period"}, {{"TotalAllocated", each List.Sum([AllocValue]), type number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each true),
#"Removed Duplicates1" = Table.Distinct(#"Filtered Rows", {"To"})
in
#"Removed Duplicates1"
The key change was ensuring the join happens on both From and PBR Period columns, which properly aligns the allocation logic period-wise. Additionally, removing duplicates based on From, To, PBR Period, and Amount prevents repeated cost entries from inflating the totals - which was the main cause of the earlier over-allocated results. So with these changes, the Tier 1 allocations now correctly match expectations without needing any manual adjustments.
Thanks again for your patience while this was being worked.
Hope this helps, and please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly.
Thank you.
Please find attached .pbix for reference.
Anonymous Thank you once again for your help and resolving my question.
I've looked at your pbix file and IT'S VERY CLOSE.
Using your pbix file, when I change the slicer to Q3FY25, the number didn't show correctly.
I believe this is the issue with the last step in PQ where you only use [To], instead of [To] and [PBR Period]. When I tried changing it, it gave me an error instead.
Below is the print screen of the error from your pbix file.
EDIT:
Marking this as solved and accept as solution.
So what I did here is make a little tweak on the PQ code, where I add "PBR Period" and add an additional step for the relationship.
In PowerBI, I edit the relationship from 'Single' to 'Both' on the Cross-filter direction. And then the number seems to work. Thus am putting this as 'Accept as Solution'
#"Removed Duplicates1" = Table.Distinct(#"Filtered Rows", {"To", "PBR Period"}),
#"Added Custom" = Table.AddColumn(#"Removed Duplicates1", "key", each [PBR Period]&";"&[To], type text)