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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Creating a Shift Column Based of Date/Time

Hi,

 

I am trying to create a new column that contains 1st and 2nd shift based off of data from my "completed" date/time column.  1st shift would be 4:30 AM - 4:29 PM and 2nd would be 4:30 PM - 4:29 AM.  I created a shift table as well, but when I create a relationship with completed, the date becomes 1899.  The idea is to create a shift slicer/toggle for management to use and determine qty completed per shift.  Any help would be greatly appreciated.

Completion ColumnCompletion ColumnShift TableShift Table  

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create a calculated table first of all, then create other columns in the new table like DAX below. Then you can create relationship between this new table and you fact data table on date field.

 

Table = SELECTCOLUMNS( CROSSJOIN( CALENDAR(MIN([COMPLETED]), MAX([COMPLETED])), GENERATESERIES( 0, TIME(23,0,0), TIME(0,30,0) ) ), "dateTime", [Date]& " " &[Value] )
 
Columns:
hour = HOUR([dateTime])
 
minute = MINUTE([dateTime])
 
key = [hour]&":"&[minute]
 
shift = var d=TIME(HOUR([dateTime]),MINUTE([dateTime]),SECOND([dateTime]))
return
IF(d>=TIME(4,30,0)&&d<=TIME(16,30,0),"1st","2st")

 

Result:

77.png

Best Regards,

Amy

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create a calculated table first of all, then create other columns in the new table like DAX below. Then you can create relationship between this new table and you fact data table on date field.

 

Table = SELECTCOLUMNS( CROSSJOIN( CALENDAR(MIN([COMPLETED]), MAX([COMPLETED])), GENERATESERIES( 0, TIME(23,0,0), TIME(0,30,0) ) ), "dateTime", [Date]& " " &[Value] )
 
Columns:
hour = HOUR([dateTime])
 
minute = MINUTE([dateTime])
 
key = [hour]&":"&[minute]
 
shift = var d=TIME(HOUR([dateTime]),MINUTE([dateTime]),SECOND([dateTime]))
return
IF(d>=TIME(4,30,0)&&d<=TIME(16,30,0),"1st","2st")

 

Result:

77.png

Best Regards,

Amy

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, what if we have 3 shifts ? 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors