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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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.

1 ACCEPTED SOLUTION

It works. Thank you.

View solution in original post

2 REPLIES 2
SamInogic
Super User
Super User

Hi @juhoneyighot 

You can try below DAX expression,

IF('stx__legacy_fsjob'[NC.IN]="","",CONVERT((LEN('stx__legacy_fsjob'[_JobType_txt])-(LEN(SUBSTITUTE('stx__legacy_fsjob'[_JobType_txt],"_","")))),STRING))


The issue was your expression have true part as blank string value and false part returning length which is numeric data type so we need to have both values of same type.

Thanks!

 

Inogic Professional Services Division

Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!

Drop an email at crm@inogic.com

Services:  http://www.inogic.com/services/

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

It works. Thank you.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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