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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
justlogmein
Helper III
Helper III

Formula for detecting local (contextual) outliers in DAX

I have created a calculated column that looks for global outliers but have found that the be insufficient as I have some data in there that, over the entire dataset, is ok but it is obviously incorrect if you look at the values around it.

justlogmein_0-1657348178536.png

I can't find a simple formula for this that I can use in DAX. Does anyone know how I could modify the DAX below so it looked at the surrounding values (excluding values that are already marked as a global outlier) and marked any anomilies?

 

=
var Q1 = 
CALCULATE
	(
	PERCENTILE.INC
		(
		'sampleDataForCalcs'[Machine Hours - Raw],0.25
		),
	FILTER
		(
		ALLEXCEPT
			(
			'sampleDataForCalcs',
			'sampleDataForCalcs'[Unit Number]
			),
		'sampleDataForCalcs'[Machine Hours - Raw] > 0
		)
	)
var Q3 = 
CALCULATE
	(
	PERCENTILE.INC
		(
		'sampleDataForCalcs'[Machine Hours - Raw],0.75
		),
	FILTER
		(
		ALLEXCEPT
			(
			'sampleDataForCalcs',
			'sampleDataForCalcs'[Unit Number]
			),
		'sampleDataForCalcs'[Machine Hours - Raw] > 0
		)
	)
var IQR = Q3 - Q1
var low = Q1 - 1.5*IQR
var high =  Q3 + 1.5*IQR
var outlier =
IF
	(
	'sampleDataForCalcs'[Machine Hours - Raw] < low
	||
	'sampleDataForCalcs'[Machine Hours - Raw] > high,
	"TRUE",
	BLANK()
	)
return outlier

 

2 REPLIES 2
justlogmein
Helper III
Helper III

Thanks, but these are not what I am looking for.

amitchandak
Super User
Super User

@justlogmein , refer if these can help outlier

https://community.powerbi.com/t5/Desktop/Removing-X-outlier-records/m-p/555551

https://bielite.com/blog/scale-down-outliers-power-bi/

https://datacornering.com/how-to-identify-outliers-in-microsoft-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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