cancel
Showing results 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.

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:

Do you guys have any idea how to do it?

1 ACCEPTED SOLUTION
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:

HTH

Pi

2 REPLIES 2
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:

HTH

Pi

Regular Visitor

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

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors