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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ArthurKvalheim
Regular Visitor

IF-formula: Comparing if one date is greater than another date returns #Error

I am trying to make a new coloumn which should state if a certain date-field is later than another date-field, but I receive the value #ERROR, and an error-message saying the DAX comparison cannot compare values of True/False with values of Text - but I have set both fields/coloumns to Date.

Any one know how to solve?

ArthurKvalheim_0-1662030806338.png

 

 



Same with Tilbuddato as this:

ArthurKvalheim_1-1662030571089.png

 

 

2 ACCEPTED SOLUTIONS

Okay, well you could always try using another IF-function outside of the current one to try to manipulate the answers back to text. 

View solution in original post

ArthurKvalheim
Regular Visitor

Finally, testing different things with good help from PowerUserR, this worked:

ArthurKvalheim_0-1662036013323.png

It seems the DAX-formula in Power BI won't let you return a text-result on this date-comparison - but with this somewhat strange workaround it will 🙂

View solution in original post

6 REPLIES 6
ArthurKvalheim
Regular Visitor

Finally, testing different things with good help from PowerUserR, this worked:

ArthurKvalheim_0-1662036013323.png

It seems the DAX-formula in Power BI won't let you return a text-result on this date-comparison - but with this somewhat strange workaround it will 🙂

ArthurKvalheim
Regular Visitor

I have now tried inserting DATEVALUE, VALUE, FORMAT and other similar to the date-fields in the logic-part of the DAX-formula with no success - but:

When I changed the result-part of the formula from "Ja" and "Nei", to 0 and 1, this seemed to solve the error.

 

This works:

ArthurKvalheim_0-1662035621087.png


All though I would like a text-result.

Okay, well you could always try using another IF-function outside of the current one to try to manipulate the answers back to text. 

PowerUserR
Solution Supplier
Solution Supplier

Hi,

I don't see any errors in the calcualtion but I was thinking that the date format of using "."  could maybe trouble dax? Try to replace with "/" and see if that works.

Appreciate your respons and suggestion. Thanks!

I have now tried different date-formats, but with no success. Still the same error-message.

ArthurKvalheim_0-1662034290406.png

 



Hi again,

Could you try using DATEDIFF?
Try setting the condition to see if it's a positive or negative

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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