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

Frequent Visitor

## Group Days and create shifts

Please can you assist me (step by step)

Please can you show me how to group into days and then create three shifts.

i.e. I have many rows for the 1st May all with different times. Then group times into 3 shifts. Shift 1 06:00-14:00, Shift 2 14:00 - 22:00 and SHift 3 22:00 - 06:00

Objective is to have a slicer where i can choose month, day and shift to see any abnormalities

Would really appreciate your support step by step

Thanks

Jerry

Hello,

1 ACCEPTED SOLUTION
Microsoft Employee

Hi @jhaldane,

```Month = Test_3[Dates].[MonthNo]

Day = Test_3[Dates].[Day]

Time = FORMAT(Test_3[Dates] ,"hh:mm:ss")

Shift =
IF (
Test_3[Time] >= TIME ( 6, 0, 0 )
&& Test_3[Time] < TIME ( 14, 0, 0 ),
"Shift1",
IF (
Test_3[Time] >= TIME ( 14, 0, 0 )
&& Test_3[Time] < TIME ( 22, 0, 0 ),
"Shift2",
"Shift3"
)
)
```

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
10 REPLIES 10
Frequent Visitor

I want to create something similar,

what i want is

shift1 - 7:30 AM  - 7:30 PM

shift2 - 7:30PM - 7:30AM,
so when user1 select shift1 then the report has to filter yesterday shift1 - 7:30 AM  - 7:30 PM and shift 2 should filter from yesterday evening 7:30PM - 7:30AM(today Morning).

Helper I

This may help:

Step 1 : Create a new column by using the following code (change the times as you want)

Shift =
IF (
[Time LOCAL] >= TIME ( 6, 0, 0 )
&& [Time LOCAL] < TIME ( 14, 0, 0 ),
"Shift1",
IF (
[Time LOCAL] >= TIME ( 14, 00, 0 )
&& [Time LOCAL] < TIME ( 22, 0, 0 ),
"Shift2",
"Shift3"
)
)

Step 2: Create another column as Payday - this column will accomodate the shift information and date

PayDay =
IF(
Query1[Shift] = "Shift1" || Query1[Shift]= "Shift2" , (Query1[Date]),
IF(Query1[Time LOCAL] >= TIME(22,00,00) && Query1[Shift] = "Shift3",
IF(Query1[Time LOCAL] <= TIME(06,00,00) && Query1[Shift] = "Shift3" ,(Query1[Date]), Query1[Date])))

Helper I

The problem that i am facing is that 3rd shift time overlaps between two days and the 3rd shift data has to be accounted for on the day the shift started.
Could you please guide me on how to do that.

New Member

I have facing the same problem. did get the solution?

That means the third shift start on the day before I have selected (10:01 pm to 12:00 pm) and continues from 12:01 to 05:59 from the day selected.

Microsoft Employee

Hi @jhaldane,

```Month = Test_3[Dates].[MonthNo]

Day = Test_3[Dates].[Day]

Time = FORMAT(Test_3[Dates] ,"hh:mm:ss")

Shift =
IF (
Test_3[Time] >= TIME ( 6, 0, 0 )
&& Test_3[Time] < TIME ( 14, 0, 0 ),
"Shift1",
IF (
Test_3[Time] >= TIME ( 14, 0, 0 )
&& Test_3[Time] < TIME ( 22, 0, 0 ),
"Shift2",
"Shift3"
)
)
```

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
New Member

Hi, this did not work for me as I continue to get an error that states operations do not support comparing values of type Text with values of type Date.  It says to consider using the Value or Format function to convert.  But then when I convert the Time column as you have suggested, it also gives me an error that says "Cannot covert value " of type Text to type Date".  Please help, I've done exactly what you've suggested and I cannot get it to work.

New Member

Hi, this does not work for me.  I have been trying this for about 30 minutes, and it continues to give me an error "cannot convert value " of type Text to type Date" when I try to convert the text to "time" as displayed in your example.  Can you help? I've done EXACTLY what you've suggested here.  Thanks.

Frequent Visitor

Thank you so much for responding.

Some questions on below.

I have managed to add the columns for month and time.

Please can you assist me with the column for 'shift'?

Where do i type in the formula for Shift?

What measure should the shift column be in?

Thanks

Jerry

```Month = Test_3[Dates].[MonthNo]

Day = Test_3[Dates].[Day]

Time = FORMAT(Test_3[Dates] ,"hh:mm:ss")```

Microsoft Employee

Hi @jhaldane,

For all above formulas in my original post, you should type them into calculated columns via clicking the highlighted button.

Create the calculated column: Month, Day and Time one by one. Then, remember to set the data type of [Time] field, as I mentioned in original post. After that, you can create the calculated column [Shift].

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

Please can you assist me (step by step)

Please can you show me how to group into days and then create three shifts.

i.e. I have many rows for the 1st May all with different times. Then group times into 3 shifts. Shift 1 06:00-14:00, Shift 2 14:00 - 22:00 and SHift 3 22:00 - 06:00

Objective is to have a slicer where i can choose month, day and shift to see any abnormalities

Would really appreciate your support step by step

Thanks

Jerry

Thank you

Jerry