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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
dbollini
Helper II
Helper II

Power Query Custom Column Error for DateTime

Hello,

 

 I am trying to write below condition for custom column if datefirst email sent is less than 24 hrs green if its equal to more than 5 days then yellow and if its more than 5 its Red but i am getting the Error below:

 

if [DateFirstEmailSent] = (Date.From(DateTime.LocalNow()))then "Green"
else if [DateFirstEmailSent] <=Date.AddDays(Date.From(DateTime.LocalNow()),5) then "Yellow" else if [DateFirstEmailSent] >= Date.AddDays(Date.From(DateTime.LocalNow()),6) then "Red" else "null"

 

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

1 ACCEPTED SOLUTION
olgad
Resident Rockstar
Resident Rockstar

Hi, your [DateFirstEmailSent] shall be date not date time, then it works, if it is a datetime, then it doesnt.

olgad_0-1698272496220.png

olgad_1-1698272577925.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

View solution in original post

4 REPLIES 4
olgad
Resident Rockstar
Resident Rockstar

Hi, your [DateFirstEmailSent] shall be date not date time, then it works, if it is a datetime, then it doesnt.

olgad_0-1698272496220.png

olgad_1-1698272577925.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Thank you and if [DateFirstEmailSent] = (Date.From(DateTime.LocalNow()))then "Green"
else if [DateFirstEmailSent] <=Date.AddDays(Date.From(DateTime.LocalNow()),5) then "Yellow" else if [DateFirstEmailSent] >= Date.AddDays(Date.From(DateTime.LocalNow()),6) then "Red" else "null"

It is looping in till second line but not looping in to the Third REd column not sure why

It is looping to Yellow if its more that 5 days but its not looping to RED or adding RED in the column if the condition is met for more than 6 days else if [DateFirstEmailSent] >= Date.AddDays(Date.From(DateTime.LocalNow()),6) then "Red" else "null"

Thank you this worked

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.