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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
JellyFishBi
Helper I
Helper I

Removing Outliers to Produce an accurate Median

Hello Datanuts!
I am analyzing helthcare providers for the Median patient Exams.  I can't seem to exclude my outliers:

The formula below gives an essence of what I am driving at.  I hope that one of you smart folks can spot the error in my ways.


MedianTotalExamCount =
CALCULATE(
MEDIANX(
SUMMARIZE(
BizLine,BizLine[ProvName],"TotExam",'4010'[TotalExam]),[TotExam]),
FILTER('4010',[TotalExam]>10))

 

 

 

1 ACCEPTED SOLUTION

@JellyFishBi 

Try this one

 

MedianTotalExamRich = CALCULATE(MEDIANX(
filter(SUMMARIZE(
'BizLine','BizLine'[RSCID],"TotExam",[TotalExam]), [TotExam] >30),[TotExam]))


I hope this helps,
Richard

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

Proud to be a Super User!


View solution in original post

10 REPLIES 10
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @JellyFishBi ,

More details will be much helpful.

It seems that your formula has no syntax error. 

If it is convenient, could you share some data sample and your desired output so that I could have a test on it?

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-piga-msft Thank you for your response! As you an see in the snip, I have fields, TotalExam, RankTotalExam(For Reference) and MedainTotalExam. Unfiltered, the Median of TotalExam is 114 which looks correct as 114 falls in the middle of the data set.

Here is the code to achieve this:

 

TotalExam.
The syntax here is:

MedianTotalExam =
CALCULATE(
MEDIANX(
SUMMARIZE(
BizLine,BizLine[ProvName],"TotExam",'4010'[TotalExam]),[TotExam]),
FILTER('4010',[TotalExam]>30))

 

 

UnfilteredUnfiltered

What i would like to do is produce a median which excludes all TotalExam records < than 30 in

TotalExam.  My desired output is to get the median of the filtered record set.


The syntax here is:

MedianTotalExam =
CALCULATE(
MEDIANX(
SUMMARIZE(
BizLine,BizLine[ProvName],"TotExam",'4010'[TotalExam]),[TotExam]),
FILTER('4010',[TotalExam]>30))

 

The Results of this are this:


FilteredFiltered

Filtering >30 Returns a null column.  Any ideas would be helpful.
Thanks for your response.

Mike

Hi @JellyFishBi ,

 

Using a very simplified version of your model, bizline 1->* to 4010 and the following measure i believe i get the desired results

 

MedianTotalExamCount = 
MEDIANX(
CALCULATETABLE(SUMMARIZE(

'BizLine','BizLine'[ProvName],"TotExam",[TotalExam]), filter('4010', [TotalExam]>30)),[TotExam])

 

now if you want the median to be the same for all bizline rows for calculate a distance for each bizline the formula is 

MedianTotalExamCount = 
CALCULATE(MEDIANX(
CALCULATETABLE(SUMMARIZE(
'BizLine','BizLine'[ProvName],"TotExam",[TotalExam]), filter('4010', [TotalExam]>30)),[TotExam]), ALL(BizLine[ProvName]))

 

 

median.png

Hope that Helps!



I hope this helps,
Richard

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

Proud to be a Super User!


@richbenmintz 

 

Hi RIch, thanks for the reponse.  For both of your solutions, my data returns a blank column.  Also, what does  bizline 1->* to 4010 mean?

 

Many thanks for your response.

 

Mike

 

Hi @JellyFishBi ,

 

Can you provide an anonymized version of your .PBIX would allow me to get the correct formula for you



I hope this helps,
Richard

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

Proud to be a Super User!


Thanks!

 

Here's a link to my google drive.  Thanks!

Medainx Outliers Pbix

@richbenmintz 

Thanks


@JellyFishBi 

Try this one

 

MedianTotalExamRich = CALCULATE(MEDIANX(
filter(SUMMARIZE(
'BizLine','BizLine'[RSCID],"TotExam",[TotalExam]), [TotExam] >30),[TotExam]))


I hope this helps,
Richard

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

Proud to be a Super User!


Rich, If you lived near me, you would not want for beer for quite some time.

 

Thank you sir.  It works as I had imagined.  I am a bit confused by the summary...Three total exams?

 

My gratitude.

 

Mike

Hi @JellyFishBi 

added some comments to the formula

--wrapping calculate not really required
MedianTotalExamRich = CALCULATE(MEDIANX( --filter summarized table
filter
(
--create summarized table
SUMMARIZE( 'BizLine','BizLine'[RSCID],"TotExam",[TotalExam])
--filter predicate for summarized table
, [TotExam] >30)
--second argument for the MedianX function
,[TotExam]))
 


I hope this helps,
Richard

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

Proud to be a Super User!


Ahhh..One to Many.  Yes, it is currently One to many. 🙂

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.