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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.