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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
xuri
Frequent Visitor

Difference of a measure and the (static) mean of multiple years

Hello,

I want to calculate the difference between a year's value and the mean value over all years as modulus.


Values:

2013: 300

2014: 170

2015: 250

2016: 320

 

Mean:

260

What I want to display in a table is:

2013  40

2014  90

2015  10

2016  60

 

I do not have my values as a column, actually, it is a measure which lists the values per year in a table visualization. The year is a column in a table and the value is a calculated measure connected the the same table.

Another problem I encountered is that the mean changes if I use a slicer and I don't get this to work properly. Does anyone have an idea how to achieve this? 

Thanks in advance
xuri

2 ACCEPTED SOLUTIONS
Daniil
Kudo Kingpin
Kudo Kingpin

Something along these lines:

Difference =
ABS (
    AVERAGEX (
        ALLSELECTED ( TheTable[Year] ),
        [The Measure]
    )
        - [The Measure]
)

View solution in original post

MFelix
Super User
Super User

Hi @xuri,

 

Taking into account that you need to have a average of the measure you can add this measure:

Difference = [Total values] - AVERAGEX(ALL(Years[Year]),[Total values])

If you want you can make the second part a easure by itself and call it mean and the do Total Values - Mean.

 

Final result is below:

mean.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
xuri
Frequent Visitor

Thank you for the quick response! Both solutions worked perfectly!

MFelix
Super User
Super User

Hi @xuri,

 

Taking into account that you need to have a average of the measure you can add this measure:

Difference = [Total values] - AVERAGEX(ALL(Years[Year]),[Total values])

If you want you can make the second part a easure by itself and call it mean and the do Total Values - Mean.

 

Final result is below:

mean.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Daniil
Kudo Kingpin
Kudo Kingpin

Something along these lines:

Difference =
ABS (
    AVERAGEX (
        ALLSELECTED ( TheTable[Year] ),
        [The Measure]
    )
        - [The Measure]
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.