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
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
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.