Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
I'm having a problem calculating the total absolute error by category.
'Table1' Data:
I created a measure to calculate the median value:
MEDIAN_VALUE = CALCULATE ( MEDIAN('Table1'[VALUE] ), FILTER ( ALL( 'Table1'), 'Table1'[Category] = MAX ( 'Table1'[Category] ) ) )
And, a measure to calculate the Absolute Error:
Absolute Error = ABS([MEDIAN_VALUE] - sum('Table1'[VALUE]))
I'm trying to get the final result to look like this when I group by Category:
But, instead of getting 7,915 for the Total Absolute Error, i'm getting 8,087.
So, it calculates the absolute error correctly when I include the PN column but when I remove it to calculate the total absolute error by category it is incorrect.
Any help would be appreciated, thank you!
Solved! Go to Solution.
It's because DAX doesn't add your rows above, instead it calulates the expression on the totals. Hence, you get 8,087.5. You need to iterate over your rows instead of looking at the totals.
Absolute Error 2 = SUMX(VALUES(Table1[PN]), [Absolute Error])
This article might be helpful for you in the future!
https://www.sqlbi.com/articles/why-power-bi-totals-might-seem-inaccurate/
Hi @agirlhasnoname ,
According to my tests, the measure you created is correct and you can get the results you want
I have created a new meaure based on the test data, you can try it and get the results you want.
MEDIAN VALUE = MEDIAN('Table'[VALUE])
Absolute_Error =
SUMX(
VALUES('Table'[Category]),
ABS(
CALCULATE([MEDIAN_VALUE], ALLEXCEPT('Table', 'Table'[Category])) -
SUM('Table'[VALUE])
)
)
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Albert @v-heq-msft
Thanks for the response. I'm trying to get 7,915 for the total absolute error not 8,087.50.
It's because DAX doesn't add your rows above, instead it calulates the expression on the totals. Hence, you get 8,087.5. You need to iterate over your rows instead of looking at the totals.
Absolute Error 2 = SUMX(VALUES(Table1[PN]), [Absolute Error])
This article might be helpful for you in the future!
https://www.sqlbi.com/articles/why-power-bi-totals-might-seem-inaccurate/
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
218 | |
88 | |
83 | |
65 | |
56 |