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
Anonymous
Not applicable

Average in Calculations

I'm trying to do some Outlier analysis, but this has led to more simple things that I'm not able to do along the way.

To keep it simple, I have a table of data with a unique REF and a numeric count of Defects.

I want to compare the number of defects on each row, to the average, so I'm first calculating the average...

EnateJon_0-1596634484486.png

If I add a column : cAveDefects = average(table[Defects]), then this is calculated for the ENTIRE table (which is fine).

 

pbi2.JPG

But my first hurdle is that this doesn't update when I filter, eg. to only thse that have 2 or less defects ?

So say I wanted to filter by some other attribute (colour) it wouldn't change either, so I'd be comparing the rows defect value with the ENTIRE table not just the filtered values.  I'm guessing I need to use CALCULATE but various attempts have failed.  Any ideas?

1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Try modiffying your DAX as follows:

cAveDefects = CALCULATE(AVERAGE(table[Defects]), ALLSELECTED(table))

 

See if this helps in your scenario.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Create a measure as suggested by @Pragati11 . The column will not change with slicer.

 

also check:https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Try modiffying your DAX as follows:

cAveDefects = CALCULATE(AVERAGE(table[Defects]), ALLSELECTED(table))

 

See if this helps in your scenario.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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.