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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Error: We cannot apply operator < to types Number and Date.

Hi!  - I get the following error when trying to perform a calculation in PowerQuery:

 

Error: We cannot apply operator < to types Number and Date.

 

Here is my formula:

 

if [Year] = 2020 and [Sample] = "AAA" and [Date] >= 5/1/2020 and [Occurance] >= 2 then [Sample2] else "Test"

 

Data Type for [Year] is Whole Number, [Sample] is Text, [Date] is Date and [Occurance] is Whole Number.

 

Could someone please help with this? Thank you in advance!! 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Exactly what you wanted to prove.

Now, make sure that power query knows the date is a date.  Use this https://learn.microsoft.com/en-us/powerquery-m/sharpdate 

View solution in original post

4 REPLIES 4
HotChilli
Super User
Super User

Exactly what you wanted to prove.

Now, make sure that power query knows the date is a date.  Use this https://learn.microsoft.com/en-us/powerquery-m/sharpdate 

Anonymous
Not applicable

amazing, worked like a charm! thank you!!

HotChilli
Super User
Super User

Here's how to debug this:-

There looks like there is only one (attempted) date comparison so, as a test, remove everything apart from the date comparison.  Still getting the error? There is something wrong with the syntax. PQ thinks one is a date and one is a number, so attempt to fix that.

See if that moves you on a bit.

Anonymous
Not applicable

Gave this a shot but still the same error: "We cannot apply operator < to types Number and Date."

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors