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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 🙂

Anonymous
Not applicable

@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 🙂

Anonymous
Not applicable

@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 🙂

Anonymous
Not applicable

@Stachu, that helped 🙂

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors