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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
palley92
New Member

How to replace outliers using DAX

I am a complete beginner with DAX, so I apologise in advance if my question has a very easy answer.

Let's say I have a dataset containing two text columns ('Var1' and 'Var2'), and a column with values called 'Values'.

I have built a PivotTable with PowerPivot, where the values are the sum of the 'Values', 'Var1' is in the rows, and 'Var2' is in the columns.

 

What I want to do is to replace those entries that are less than 3 standard deviations below the average across Var1 (but not including Var2) with 0's. 

 

Simply put, I am looking to have a measure that does the following:

calculate the average grouped by Var1, then the standard deviation grouped by var1. Is each value in the pivot table (which is actually grouped by Var1 and Var2) less than the average minus 3x the standard deviation? If so, replace with 0, otherwise keep the value.

 

Many thanks

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I think the below should work

Replace Outliers =
VAR var1 =
    ALL ( 'Table'[Var1] )
VAR avg =
    AVERAGEX ( var1, CALCULATE ( SUM ( 'Table1'[Value] ) ) )
VAR stdDev =
    STDEVX.P ( var1, CALCULATE ( SUM ( 'Table1'[Value] ) ) )
VAR currentVal =
    CALCULATE ( SUM ( 'Table1'[Value] ) )
RETURN
    IF ( currentVal < avg - ( stdDev * 3 ), 0, currentVal )

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

I think the below should work

Replace Outliers =
VAR var1 =
    ALL ( 'Table'[Var1] )
VAR avg =
    AVERAGEX ( var1, CALCULATE ( SUM ( 'Table1'[Value] ) ) )
VAR stdDev =
    STDEVX.P ( var1, CALCULATE ( SUM ( 'Table1'[Value] ) ) )
VAR currentVal =
    CALCULATE ( SUM ( 'Table1'[Value] ) )
RETURN
    IF ( currentVal < avg - ( stdDev * 3 ), 0, currentVal )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.