Forum Discussion
Dynamic Filtered Measure for P&L Reporting
I'm a long-time excel user/modler but a newbie on BI so apolgies in advance. I'm attempting to build out som P&L dashboarding for my company. I have a chart of accounts that I've created naming hierarchies for. So far, they are generically (from higher to lower) Heirarchy 1 / Hierarchy 2 / Account Name. I wanted to create a custom measure to represent margin, i.e. any given filtered layer divided by sales. The following measure did give me the result I wanted, however, it only allows me to filter by Hierarchy 1. I would like to be able to slice and dice by any level of P&L hierarchy and still have it take those results divided by Product Net Sales as defined by Hierarchy 1. Is there a way to do this either directly or indirectly? I assumed it would still work but when I filter for anything but Hierarchy 1, my margin number disappears.
- Anonymous2 years ago
Hi mcgibson45 ,
I create a table as you mentioned.
Then I think you can change your DAX code and here is the changed DAX code.
Measure 2 = DIVIDE ( SUM ( 'Consolidated P&L'[Amount] ), CALCULATE ( SUM ( 'Consolidated P&L'[Amount] ), 'Consolidated P&L'[Hierarchy 1] = "Product Net Sales", ALL ( 'Consolidated P&L'[Hierarchy 2], 'Consolidated P&L'[Account Name] ) ) )Next I add two slicers and get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
Hi mcgibson45 ,
I create a table as you mentioned.
Then I think you can change your DAX code and here is the changed DAX code.
Measure 2 = DIVIDE ( SUM ( 'Consolidated P&L'[Amount] ), CALCULATE ( SUM ( 'Consolidated P&L'[Amount] ), 'Consolidated P&L'[Hierarchy 1] = "Product Net Sales", ALL ( 'Consolidated P&L'[Hierarchy 2], 'Consolidated P&L'[Account Name] ) ) )Next I add two slicers and get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- mcgibson45New Member
That looks like it does the trick! Thank you for a taking a moment to help me out. I really appreciate it.