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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nilotpalc
Frequent Visitor

Power BI DAX - Running the MEDIAN or MEDIANX formula for a calculated column gives error message

I have been trying to generate a calculated column within Power BI Desktop using the MEDIAN formula to get the median age. I checked to see if there were any inconsistencies like text data or blank data within the Age column but, did not find any such instances. The error message is as follows -

Expressions that yield variant data-type cannot be used to define calculated columns.

I created a median measure and no error was observed. I also ran the statistic function in the query stage and it gave me, 27 as the median age for the entire dataset. I expected the data column to have a single value equal to 27 being shown in the calculated column.

 

Any help will be greatly appreciated.

 

Error MessageError Message

Age Column FormatAge Column Format

4 REPLIES 4
nilotpalc
Frequent Visitor

Hi all,

I found the answer on the link here

 

That's a good one @nilotpalc , will have to remember that!! 🙂

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

What is the formula for your Age column? Can you provide the file?


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  The Age Column is just a number and there is no formula for the same.

The xlsx file used is shared on this link

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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