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

Hierarchy average as per case statement

Hi All,

 

I Have below data 

 

CategorySub CategoryValue
A  
 A21
 A112
B  
 B36
 B117

I need to give switch case as following 

 

CategorySub CategoryValueAverageCOn
A    
 A211Low
 A1124High
B    
 B363Medium
 B1176High

 

Dax used :

Average = round(AVERAGE(Data[Value]),0)
COn = SWITCH(TRUE(),Data[Average]<2,"Low",
Data[Average]=3,"Medium","High")
 
Expected o/p
Expected O/p   
CategorySub CategorylowMediumHigh
A 1 12
 A21 12
 A1   
B  617
 B3 6 
 B1  17

As in Power bi Am taking in matrix hierarchy category level values are not correctly adding up and Average value is changing in Category level and wrong values are being displayed.

What ever value we are getting at Subcategory level should be added to Category.

 

@dax Hierarchy average @amitchandak @v-kkf-msft 

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

I used some virtual data to test, and the results are in line with expectations. Could you share an example pbix to let me know your scene better?

Vlianlmsft_0-1649303296295.png

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Assume after subcategory level you want to sum /add the measure Average 

 

then

sumx(Values(Table[Sub category]),[Average])

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.

Top Solution Authors