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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
djj13
Regular Visitor

Creating Business Date in Date Table

I have a report that is generated by our Point-of-Sale system. The report has the date/time a check is opened and when it is closed.

 

Our business day for this report runs from 3:00AM - 2:59 AM. I need to add a date column to represent the business/transaction day. 

 

Open Date/Time AFTER 1/1/2020 3:00:00 AM  Close Date/Time BEFORE 1/2/2020 2:59:00 AM =  Business Date of 1/1/2020.

 

Examples:

 

Open Date/Time          Close Date/Time               Business Date

1/1/2020 09:00:00 AM    1/1/2020 09:30:00 AM    1/1/2020

1/1/2020 11:00:00 PM    1/2/2020 01:30:00 AM    1/1/2020

1/2/2020 01:00:00 AM    1/2/2020 02:00:00 AM    1/1/2020

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@djj13 , Try a new column like

 

Business Date =
Switch( true(),
hour([Open Date/Time]) >= 3 , [Open Date/Time].date , // or use date(year([Open Date/Time]), month([Open Date/Time]), day([Open Date/Time])) ,
hour([Close Date/Time]) < 3 ,[Open Date/Time].date  -1,
[Open Date/Time].date
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@djj13 , Try a new column like

 

Business Date =
Switch( true(),
hour([Open Date/Time]) >= 3 , [Open Date/Time].date , // or use date(year([Open Date/Time]), month([Open Date/Time]), day([Open Date/Time])) ,
hour([Close Date/Time]) < 3 ,[Open Date/Time].date  -1,
[Open Date/Time].date
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you! This worked. I tried using [Open Date/Time].date but received a syntax error for the date function.

 

dj.

mahoneypat
Microsoft Employee
Microsoft Employee

You can use a column expression like this to do that.

 

Business Date 2 = var thisdate = DATE(YEAR('Table'[Open Date/Time]), MONTH('Table'[Open Date/Time]), DAY('Table'[Open Date/Time]))
return if(HOUR('Table'[Open Date/Time])<3, thisdate -1, thisdate)
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors