cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors