cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SoufTC
Helper I
Helper I

Subtotals in Matrix with Hierarchy not adding up

Hello everyone,

I'm struggling to solve this problem !

So, I have this hierarchy in matrix with 2 level between two table linked with column "City"

level 1 : "RESP CONTENT"

level2 : "City"

I created the matrix as below as below using as hierarchy the columns of "table 1" :  "RESP CONTENT" and "City"

 

SoufTC_0-1646034995888.png

With :

CM = SWITCH (
TRUE,
HASONEVALUE(table1[City]) && HASONEVALUE(table1[RESP CONTENT]),
[Score],
NOT(HASONEVALUE(table1[City])) && HASONEVALUE(table1[RESP CONTENT]),
SUMX(VALUES(table1[City]),[Score]),
SUMX(VALUES(table1[City]),[Score])
)
 
Everything works but when I remove the filter of "RESP CONTENT" the total of level 1 "RESP CONTENT" is wrong as below :
 
SoufTC_1-1646035447441.png

 

Please, any help?

Thank's in advance

1 ACCEPTED SOLUTION

HI @SoufTC,

I think you need to add if statements to check all hierarchy levels and write corresponding expressions for each level aggregation.

Clever Hierarchy Handling in DAX - SQLBI

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@SoufTC , as Score is measure

 

then for sum

sumx(Table, [Score])

 

or Sumx(values(Table[Column]), [Score])  // After Column, any group by it will sum

@amitchandak  thank you but it only works for level 2 !

HI @SoufTC,

I think you need to add if statements to check all hierarchy levels and write corresponding expressions for each level aggregation.

Clever Hierarchy Handling in DAX - SQLBI

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors