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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.