Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum Hierarchy Levels based on selection

I have a hierarchy table and would like to display total based on what level the slicer is selected.

 

Sample.gif

 

If all Level 3 (Division) checkboxes selected, display sum of Level 2 (BU) total across all groups

If all Level 2(BU) checkboxes selected, display sum of Level 1(Group) total across all group

If not all Level 3 checkboxes selcted (regardless of BU), display selected Level 3 (Division) total across all BUs

If not all Level 2 checkboxes selcted (regardless of Group), display selected Level 2 (BU)total across all groups.

Below are some examples:

If Audit, SPU, YAD selected, display sum of (Audit, SPU, YAD)

If 7JB and F8C selected, display sum of (7jb and f8c)

If OC9 selected and Audit selected, display sum of (DIM, TIF and Audit)

 

This is the formula that I currently have.  It works for Divsion level and Group (Group works when no selection is made in the hierarchy)

myTotal = if (ISFILTERED(DataView[DIVISION]),[DIVISION_AMT],if(ISFILTERED(DataView[BU]),[BU_AMT],[GROUP_AMT]))

3 REPLIES 3
Greg_Deckler
Super User
Super User

Going to need example data for this one. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, take a look at my Matrix Measure Total Triple Threat Rock & Roll, it solves a similar problem to this and the techniques used might apply.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Matrix-Measure-Total-Triple-Threat-Rock-amp-...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Anonymous,

 

Unfortunately, it is really impossible to meet your requirement. However we can add normal slicers and create three measures to work around. Here are the formulas.

 

sum Div = IF(calculate(distinctcount([DMSION]),allselected(Table1[DMSION]))=CALCULATE(DISTINCTCOUNT(Table1[DMSION]),ALL(Table1)),SUM(Table1[BU_AMT]),CALCULATE(SUM(Table1[DIVISION_AMT]),ALLSELECTED(Table1[DMSION])))
group sum = IF(CALCULATE(DISTINCTCOUNT(Table1[Group]),ALLSELECTED(Table1[Group]))=CALCULATE(DISTINCTCOUNT(Table1[Group]),ALL(Table1)),SUM(Table1[GROUP_AMT]),CALCULATE(SUM(Table1[GROUP_AMT]),ALLSELECTED(Table1[Group])))
BU sum = IF(CALCULATE(DISTINCTCOUNT(Table1[BU]),ALLSELECTED(Table1[BU]))=CALCULATE(DISTINCTCOUNT(Table1[BU]),ALL(Table1)),SUM(Table1[GROUP_AMT]),CALCULATE(SUM(Table1[BU_AMT]),ALLSELECTED(Table1[BU])))

123.png 

For more details, please check the pbix as attached.

 

https://www.dropbox.com/s/ib2a3myc5fafbc6/suma2.pbix?dl=0

 

Regards,

Frank

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks for the feeback.  I'll have to present this as an alternate.  Do you think this can be accomplished with M Query?  I've never done anything using M Query.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.