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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
DJBAJG
Helper III
Helper III

Median of multiple columns (some columns have blanks)

I need a method for calculaing the median of multiple (3) columns. I tried using MEIDIANX but realized it was taking blanks and zeros into account and providing incorrect results. I then tried to add a FILTER to the argument but got an error saying "Expressions that yield variant data-type cannot be used to define calculated columns." so I'm at a loss now. I'm unable to supply the data as it's incredibly large and contains sensitive elements. This is what I had written:

 

New Column=

MEDIANX(

FILTER(

'tableA',{'tableA[column1],'tableA',{'tableA[column2],'tableA',{'tableA[column3]} <> BLANK() ),

{'tableA[column1],'tableA',{'tableA[column2],'tableA',{'tableA[column3]})

 

I also tried lots of other combinations of including or not including the table names, using a VALUE expression, none of which produced accurate results and most of which produced syntax errors. I'm sure this is incredibly simple but I'm at a loss. I'm still very new to DAX and getting more frustrated every day. I appreciate any and all help.

 

Thanks. 

6 REPLIES 6
Uldevi
Frequent Visitor

Hi, I have got same issue regarding MEDIANX did you get any solution for that , can you share with me how can I achieve it.....Thank you !

Greg_Deckler
Super User
Super User

@DJBAJG Probably should unpivot, but if you don't want to do that, https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...

 

Also, make sure to read this to avoid pain and suffering!! https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-MEDIAN/m-p/1322755#M599



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I don't think this works. Here's a screenshot of my output and the measure. The dark blue bar in the graph should represent the median of all of the values in the chart, ignoring blanks. 17 non-blank values, order, take the middle. That would give us $2,500. I tried a few different ways but I'm actually unable to get $1,225. What am I missing? Does this not work when filtered? 

 

Table.PNG

 

You can see I'm using 5 columns. Did it do the measure incorrectly when creating the tmpTable?

 

Code.PNG

 

 

Just figured it out. Because it's using MEDIANX it's taking the blanks into account and treating them as zeros. This doesn't work for me. Any way around this in your example of do we need a different solution? 

Come on community. I've a newbie here and this is probably incredibly simple. 

Please! Still need help here. I'm spinning my wheels getting nowhere on my own. 😞 

Here's the answer. Like I assumed, incredibly simple for probaly 99% of the people on this forum but tough for me. Wish someone would have chimed in. Could have saved my a day....

 

Capture.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

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

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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