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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
VulnBi
Regular Visitor

Incorrect Total for DAX Measure in Matrix

Hello,

I use the following DAX formula which is giving me incorrect grand totals in my Matrix in Power Bi. The values in the rows are correct, but how it's summarized is not. The correct total would be: 30084

 

I am new to DAX so any hint or advice would be much appreciated.

Measure = COUNT(Table1[Field1]) * COUNT(Table2[Field2])

VulnBi_0-1730746726187.png

 

2 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

hi @VulnBi 

 

supposing you have fieldx in table1 as the row for the matrix, try like:

Measure =

SUMX(

VALUES(table1[fieldx]),

COUNT(Table1[Field1]) * COUNT(Table2[Field2])

)

 

View solution in original post

Anonymous
Not applicable

Hi FreemanZ ,thanks for the quick reply, I'll add more.

Hi @VulnBi ,

The total row does not have a filtering effect; it essentially multiplies the number of rows in your entire table, which results in such a large value. Also, the calculation of the total row is based on your measure, and since you want to get the sum, but your calculation is currently a multiplication, you should modify your DAX expression.

Like this

 

Measure = 
VAR _istotalrow = SELECTEDVALUE('Table'[ID])
VAR _resultSet = SUMMARIZE('Table','Table'[ID],"Result",COUNT('Table'[Field1]) * COUNT('Table'[Field2]))
RETURN 
IF(ISBLANK(_istotalrow),SUMX(_resultSet,[Result]),COUNT('Table'[Field1]) * COUNT('Table'[Field2]))

 

vzhouwenmsft_1-1730776009742.png

The '_resultSet' is a virtual table that stores the results of the calculations in advance, and finally uses the 'Selectedvalue' function to determine if the rows are totals. If so, the results in the virtual table are summed. If there is something you do not understand, feel free to ask questions.

 

Best Regards,
Wenbin Zhou

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi FreemanZ ,thanks for the quick reply, I'll add more.

Hi @VulnBi ,

The total row does not have a filtering effect; it essentially multiplies the number of rows in your entire table, which results in such a large value. Also, the calculation of the total row is based on your measure, and since you want to get the sum, but your calculation is currently a multiplication, you should modify your DAX expression.

Like this

 

Measure = 
VAR _istotalrow = SELECTEDVALUE('Table'[ID])
VAR _resultSet = SUMMARIZE('Table','Table'[ID],"Result",COUNT('Table'[Field1]) * COUNT('Table'[Field2]))
RETURN 
IF(ISBLANK(_istotalrow),SUMX(_resultSet,[Result]),COUNT('Table'[Field1]) * COUNT('Table'[Field2]))

 

vzhouwenmsft_1-1730776009742.png

The '_resultSet' is a virtual table that stores the results of the calculations in advance, and finally uses the 'Selectedvalue' function to determine if the rows are totals. If so, the results in the virtual table are summed. If there is something you do not understand, feel free to ask questions.

 

Best Regards,
Wenbin Zhou

FreemanZ
Super User
Super User

hi @VulnBi 

 

supposing you have fieldx in table1 as the row for the matrix, try like:

Measure =

SUMX(

VALUES(table1[fieldx]),

COUNT(Table1[Field1]) * COUNT(Table2[Field2])

)

 

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.