Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin 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.
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])
Solved! Go to Solution.
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])
)
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]))
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
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]))
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
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])
)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
16 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
23 | |
11 | |
10 | |
10 | |
8 |