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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.