Forum Discussion
Ira_27
1 year agoHelper II
Power Query - Recursive decomposition of rows
Hello Community Members, I am trying to get some help with a scenario we are dealing with. We have daily holdings data and need a way to drill into the subsequent fund holdings to find % investme...
- 1 year ago
Hello Ira_27,
Can you please try this approach:
1. Create a Recursive Table
DecomposedHoldings = VAR FundHoldings = GENERATE( 'Holdings', FILTER( 'Holdings', 'Holdings'[FundID] = EARLIER('Holdings'[AccountID]) ) ) RETURN UNION('Holdings', FundHoldings)2. Calculate % Investment
% Investment = VAR TotalMV = CALCULATE( SUM('DecomposedHoldings'[MV]), ALL('DecomposedHoldings') ) RETURN DIVIDE(SUM('DecomposedHoldings'[MV]), TotalMV, 0)3. If the semantic model's size is an issue, filter the data in Power Query:
FilteredHoldings = Table.SelectRows( Source, each [HoldingDate] >= Date.AddMonths(DateTime.LocalNow(), -24) )Hope this helps!
Ira_27
1 year agoHelper II
I tried your approach but the decomposition only goes one level down. apparently i have atleast 2 levels to recurse over. Any thoughts on how to handle that?