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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Super User
Super User

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
Super User
Super User

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.