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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
fairy
New Member

which operator to use to compare date column with a date value?

Hi

I an trying to do the following while Adding a custom column. col1 and col2 are of date type

 

if [col1] < #date(2016,7,6) then "Grey"

else if ([col2] > #date(2016,7,6) and [col3] = "Yellow") then "Grey"

else [col3]

 

I get error saying cannot apply operator < to type Date. How do I compare dates in here?

 

 

 

1 ACCEPTED SOLUTION

You can change

#date(2016,7,6) 

to

#datetime(2016,7,6,0,0,0) 

and it should work 🙂

 

 

View solution in original post

3 REPLIES 3
arify
Employee
Employee

When I run "#date(2011,1,1) < #date(2015,1,1)" I get true, so that's not the issue.

 

What's the exact error message? Are you sure all of the column values are dates?

 

Are you getting something like this? We cannot apply operator < to types Date and DateTime.

 

Thanks

Yes that right. thats exactly the error message I get. how do I resolve this?

 

The workaround I did was use DAX in power BI desktop instead of M in Edit query. However, I still want the M to work

 

 

 

You can change

#date(2016,7,6) 

to

#datetime(2016,7,6,0,0,0) 

and it should work 🙂

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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