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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

IF Statement Help - Greater than less than days overdue

Hello Community,

I am trying to output a value to a custom column that is based on greater than x but less than x days over due.

Formula

 

if Duration.Days(DateTime.LocalNow() - [Date Due])>=1 and [Date Due]<7 then "1-7" else null

Error

Expression.Error: We cannot apply operator < to types Number and DateTime.
Details:
Operator=<
Left=7
Right=20/08/2014 23:00:00

 

Any help would be much appreciated!

Thanks, Mark

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

you basically need same comparison as you do for 1, right now you compare [Date Due] which is datetime type (when converted to numeric it's 40k+) with numeric 7

if Duration.Days(DateTime.LocalNow() - [Date Due])>=1 and Duration.Days(DateTime.LocalNow()-[Date Due])<7 then "1-7" else null


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
Stachu
Community Champion
Community Champion

you basically need same comparison as you do for 1, right now you compare [Date Due] which is datetime type (when converted to numeric it's 40k+) with numeric 7

if Duration.Days(DateTime.LocalNow() - [Date Due])>=1 and Duration.Days(DateTime.LocalNow()-[Date Due])<7 then "1-7" else null


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

That worked perfectly. Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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