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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ReyDeSirenas
Regular Visitor

Create shift from time

Hi,

 

I´ve been trying to figure this out. So basically I want to create a new table named "Shift" with only two values: Shift 1 and Shift 2.

Shift 1 goes from 07:30 to 19:30 and Shift 2 goes from 19:30 to 07:30. These shifts are for all days of the week. 

 

Days of the week are seen as numbers, not text. This is how it looks:

 

ReyDeSirenas_0-1681163189843.png

 

Do you guys have any idea how to do it?

1 ACCEPTED SOLUTION
PiEye
Resolver II
Resolver II

Hi @ReyDeSirenas  in DAX this is simple to achieve as dates and times work similar to numbers, and you can perform greater than / less than comparisons easily.

 

This expression as a calculated column (ie, not measure) in the same table as the time element should work.

Shift = "Shift " & If('Days and hours'[Time] >= time(7,30,0) && 'Days and hours'[Time] < time(19,30,0), 1,2)

 

Result:

PiEye_0-1681215383473.png

 

HTH

 

Pi

 

 

View solution in original post

2 REPLIES 2
PiEye
Resolver II
Resolver II

Hi @ReyDeSirenas  in DAX this is simple to achieve as dates and times work similar to numbers, and you can perform greater than / less than comparisons easily.

 

This expression as a calculated column (ie, not measure) in the same table as the time element should work.

Shift = "Shift " & If('Days and hours'[Time] >= time(7,30,0) && 'Days and hours'[Time] < time(19,30,0), 1,2)

 

Result:

PiEye_0-1681215383473.png

 

HTH

 

Pi

 

 

Thanks a lot! That worked and you help me a lot to understand how it works!

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.