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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.