Forum Discussion
Measure gives wrong Total
Dear guru of PowerBI,
I've Two tables :
- Server (which has all information about each server)
- Server_unpivot (unpivoted version of Server table which has
column_name (value of unpivoted column, that could be like Hostname,Ip address, OS etc etc)
hostname_value
value (value of unpivoted row)
extraction_date )
All Null values has been proofed with "(NULL)" and I have to calcolate the missing fields for each column of UnPivoted table.
I have to calculate for each column the number of "(NULL)" values in the last date available, so I wrote this DAX :
# Missing Fields = CALCULATE( COUNTROWS('server_unpivot'),
FILTER('server_unpivot','server_unpivot'[value] = "(NULL)"),
FILTER('server_unpivot', 'server_unpivot'[extraction_date] = MAX('server_unpivot'[extraction_date])))
I've applied the measure and this is the result.
The total is wrong, it's like he doesn't does the sum of the column as I want it.
So I tried to correct the formula in this way :
# Missing Fields correct = IF(HASONEFILTER('server_unpivot'[host_name_value]),[# Missing Fields],SUMX(VALUES('server_unpivot'[host_name_value]),[# Missing Fields]))
but it doesn't give still the correct result.
For the total I need the sum of the # missing fields in the column.
This is the data model.
Could you please help me in fixing this formula?
Hi, fe_username
According to your description, your Total value for Matrix in Power BI Desktop does not return the correct value. This is a very common problem in Power BI development because Meaure is calculated in a filtered context, and the values computed in the overall context of Total may not be cumulative above.
In order for the Total value to return the correct cumulative value, we need to create another measure based on the current measure and the field you placed,like this:
SUMX(VALUES('Table'[column_name]), [# Missing Fields] )If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
1 Reply
- v-yueyunzh-msftCommunity Support
Hi, fe_username
According to your description, your Total value for Matrix in Power BI Desktop does not return the correct value. This is a very common problem in Power BI development because Meaure is calculated in a filtered context, and the values computed in the overall context of Total may not be cumulative above.
In order for the Total value to return the correct cumulative value, we need to create another measure based on the current measure and the field you placed,like this:
SUMX(VALUES('Table'[column_name]), [# Missing Fields] )If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly