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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
juhoneyighot
Helper III
Helper III

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

Hi! I'm new to PowerBI.

I'm using the IF statement, unfortunately I'm getting this error "Expressions that yield variant data-type cannot be used to define calculated columns."

Calculated Column: IF('stx__legacy_fsjob'[NC.IN]="","",(LEN('stx__legacy_fsjob'[_JobType_txt])-(LEN(SUBSTITUTE('stx__legacy_fsjob'[_JobType_txt],"_","")))))

 

Can anyone help me on this.

Thank you.

2 REPLIES 2
audreygerred
Super User
Super User

Hello! You might have a data type mismatch. In your DAX expression, you are combining different data types (e.g., text and integer) in the calculations. If Power BI cannot determine a consistent data type for the calculated column, it will result in a variant data type.

For example, if the "NC.IN" column in your data model contains both text and empty values, and you're trying to perform mathematical operations and string manipulations on the "JobType_txt" column, it might result in variant data types when there is a mix of data types involved.





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

Proud to be a Super User!





HotChilli
Super User
Super User

All it means is that all data returned in the IF statement should be of the same type.  It looks like this one is returning text or numbers

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.