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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
agirlhasnoname
New Member

Incorrect Measure Total

Hello,


I'm having a problem calculating the total absolute error by category. 

'Table1' Data:

 agirlhasnoname_3-1708530606490.png

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]))  

agirlhasnoname_6-1708531855130.png


I'm trying to get the final result to look like this when I group by Category: 
agirlhasnoname_5-1708530764781.png
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!

 

 

1 ACCEPTED 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])

 

Syk_0-1708612440954.png

 

 

 


This article might be helpful for you in the future!
https://www.sqlbi.com/articles/why-power-bi-totals-might-seem-inaccurate/

View solution in original post

4 REPLIES 4
v-heq-msft
Community Support
Community Support

Hi @agirlhasnoname ,
According to my tests, the measure you created is correct and you can get the results you want

vheqmsft_0-1708568040024.png

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])
    )
)

vheqmsft_1-1708568185484.png

 

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. 

agirlhasnoname_0-1708611597073.png

 

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])

 

Syk_0-1708612440954.png

 

 

 


This article might be helpful for you in the future!
https://www.sqlbi.com/articles/why-power-bi-totals-might-seem-inaccurate/

@Syk thank you, that worked!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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