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
JeanMariePBI
Helper I
Helper I

IF statement in CC, getting error "Expressions that yield variant data-type cannot be used to define

I have a Table named "Rebates Paid" and the table has a Column that holds the Rebates Paid Amount but that value can be either USD or CAD depending on the row.   I have another column, called [Currency] which holds the currency type(either USD or CAD). 

 

I've created a Measure named[_CAD]  to store the exchange rate I want applied to the CAD rows only.

 

I'm trying to add a simple IF Statement to a Calc Column so that I can convert any rows that have CAD currency to USD, otherwise I want to use the value found in the Rebate Paid Amount.  If statement is as follows:

 

 =IF('Rebates Paid'[Currency]="CAD",'Rebates Paid'[Total Rebates Paid]/[_CAD],'Rebates Paid'[Total Rebates Paid])
 
However, I get this error message: "Expressions that yield variant data-type cannot be used to define"
 
Any idea why I am seeing this?
3 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

Typically, you get this sort of error when your if returns text for one result and a number for the other. This situation doesn't look like it has text output though.

 

What are the data types for the [Total Rebates Paid] column and [_CAD]?

View solution in original post

VahidDM
Super User
Super User

Hi @JeanMariePBI 

 

Based on the error message, it is caused by the different data types in column.

Check the 'Rebates Paid'[Currency] and 'Rebates Paid'[Total Rebates Paid] data types.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

New Year Power BI eCard:

 

https://community.powerbi.com/t5/Data-Stories-Gallery/Happy-New-Year/td-p/2266398

 

 

 

eb50dd_d85fbe053af7491e915ca41732d978a7~mv2

 

 

 

 

View solution in original post

Hello Alexis,  the data type for Total Rebates Paid and CAD are both numeric which is why I don't understand the error message.

 

View solution in original post

5 REPLIES 5
VahidDM
Super User
Super User

Hi @JeanMariePBI 

 

Based on the error message, it is caused by the different data types in column.

Check the 'Rebates Paid'[Currency] and 'Rebates Paid'[Total Rebates Paid] data types.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

New Year Power BI eCard:

 

https://community.powerbi.com/t5/Data-Stories-Gallery/Happy-New-Year/td-p/2266398

 

 

 

eb50dd_d85fbe053af7491e915ca41732d978a7~mv2

 

 

 

 

Thank you!  This worked.  One of the columns had a AlphaNumeric data type.  Once I switched it over to Numeric the issue resolved.   Happy New Year!

 

 

AlexisOlson
Super User
Super User

Typically, you get this sort of error when your if returns text for one result and a number for the other. This situation doesn't look like it has text output though.

 

What are the data types for the [Total Rebates Paid] column and [_CAD]?

Hello Alexis,  the data type for Total Rebates Paid and CAD are both numeric which is why I don't understand the error message.

 

Actually, I just did a double check and the Rebates Paid did have a AlphaNumeric data type.  I've switched it over to numeric and it resolved the issue.   thank you so much!  Happy New Year!

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.

Top Solution Authors