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
vmakhija
Post Prodigy
Post Prodigy

Error in calc column for MEDIAN

Hello

 

I have this simple column for which I am trying to calcualte a MEDIAN value as below.

But it gives an error saying -- "Expressions that yield variant data-type cannot be used to defined calculated columns"

 

Any inputs on this?

 

MEDIAN.JPG

 

 

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

hmm, for even number of items median can be decimal number even if it's based on Whole numbers.
can you try switching data type to Decimal with format as Whole?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

6 REPLIES 6
Stachu
Community Champion
Community Champion

I'm not 100% sure, but I think that you need to change the data type of Column1 from Any to Number



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@Stachu

Column1 is already of datatype "Whole Number"

Stachu
Community Champion
Community Champion

are you sure it's the data type and not format? they're just next to each other in the UI
unless you changed it in the query editor, then it must be something else - are there any non numeric values in that column?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@Stachu

Yup, both are "Whole Number". See below -

 

 

FORMAT.JPG

 

 

 

 

 

 

There are no non-numeric values in this column. My earlier screenshot shows all the values available for this column.

 

Stachu
Community Champion
Community Champion

hmm, for even number of items median can be decimal number even if it's based on Whole numbers.
can you try switching data type to Decimal with format as Whole?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@Stachu, that helped 🙂

Now I think of it, it was so silly one to not think of.

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.