cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
harinikambam
Frequent Visitor

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 @harinikambam ,

 

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

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

 

then

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

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!