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
TheBaz_57
Frequent Visitor

"Add one day to date if time between" works sometimes, not always

Hi all,

 

I have in powerbi a table that is like this:

TheBaz_57_0-1713345362364.png

 

I have a column with Time, Date and Business date. For some reason my business day is from D-1 21:00:00 to D 21:00:00.

So I want to get the business date by adding 1day to the date when time is between 21:00:00 and 23:59:59. 

 

The column "business date" is a caculated column with this formula: 

Business Date = IF(ODRs[Time]>TIME(21,00,00) && ODRs[Time]<TIME(23,59,59), DATEADD(ODRs[Date],1,DAY))
 
However, as you can below from the image sometimes it works sometimes not.
i.e why 21:47:52 is considered on not 23:18:24 ?
 
TheBaz_57_1-1713345631411.png

 

Thank you

 

 

1 ACCEPTED SOLUTION
TheBaz_57
Frequent Visitor

Seems it is returning blank when day calculated by DATEADD is a weekend.

Solved it by having a calculated column with WEEKDAY, return the day of the week and my column business day is calculated with IF WEEKDAY = 6 DATEADD+2 else +1

View solution in original post

1 REPLY 1
TheBaz_57
Frequent Visitor

Seems it is returning blank when day calculated by DATEADD is a weekend.

Solved it by having a calculated column with WEEKDAY, return the day of the week and my column business day is calculated with IF WEEKDAY = 6 DATEADD+2 else +1

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.