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
Anonymous
Not applicable

Using dates with IF function

Hello 

 

I am getting error ("Expressions that yield variant data-type cannot be used to define calculated columns")

when using two dates in an IF function. 

 

IF('Outstanding Cases'[CreatedDate]<=TODAY()-1,"Y",0)
 
Does anyone have any idea with regards to this?
 
Many thanks
1 ACCEPTED SOLUTION
Anonymous
Not applicable

The expression below is not power query. Are you looking for a power query expression?

 

While I do not know what you are using, my guess would be that the message is tellling you that an if statement cannot return both a string "Y" and a number 0. Maybe you can try the expression below:

 

IF('Outstanding Cases'[CreatedDate]<=TODAY()-1,"Y","0")

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

The expression below is not power query. Are you looking for a power query expression?

 

While I do not know what you are using, my guess would be that the message is tellling you that an if statement cannot return both a string "Y" and a number 0. Maybe you can try the expression below:

 

IF('Outstanding Cases'[CreatedDate]<=TODAY()-1,"Y","0")

Anonymous
Not applicable

Hi 

 

Apologies, I must have accidently posted it in the wrong section. 

 

However, you're solution has worked great, thank you.

 

Kind regards

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
Top Kudoed Authors