Hi There,
This is a real life manufacturing issue that i have reporting out data. The data I report out is Booked Hours (Someone books on a job and off a job, is equal to a booking in hours), over a 3 shift period, starting Sunday Night Shift (N/S) and finishing Friday Back Shift (B/S). I then use the data to create the shown Pivot Table.
The code works fine, and generates the data shown in the table below.
Night Shift (N/S) - Starts on Sunday at 22:30 and finishes on Monday at 07:00......the next Night Shift is Monday at 22:30 and finishes on Tuesday at 07:00........and so on until it finishes on Friday at 07:00
Early Shift (E/S) - Starts on Monday at 07:00 and finishes at 15:00..........Monday to Friday
Back Shift (B/S) - Starts on Monday at 15:00 and finishes at 22:30..........Monday to Friday
The issue i have is that the Pivot Table is based on the Table below, and the Table doesnt show N/S correctly as the days overlap. E/S and B/S are perfect as the sum of booked hours is based on the same day. What i want to show on the Pivot Table is all the booked hours for Sunday N/S, Monday N/S, Tuesday N/S, Wednesday N/S & Thursday N/S. The current way it shows, is some of Sunday N/S (22:30 to 23:59) is captured on the Pivot table as Sunday N/S, however the rest of the Sunday N/S between 00:00 and 07:00 is shown under Monday N/S......along with Monday (N/S 22:30 to 23:59)
I hope i have explained this correctly and sorry for the long winded explanation
let
Source = Excel.CurrentWorkbook(){[Name="fLabourReport"]}[Content],
DT = Table.TransformColumnTypes(Source,{{"StartTime", type datetime}, {"StopTime", type datetime}}),
DayName = Table.AddColumn(DT, "Day Name", each Date.DayOfWeekName([StartTime]), type text),
Time = Table.TransformColumnTypes(DayName,{{"StopTime", type time}}),
Conditions = Table.AddColumn(Time, "Shift",
each if [StopTime] >= #time(22, 30, 0) or [StopTime] <= #time(6, 59, 59) then "N/S"
else if [StopTime] >= #time(15, 0, 0) and [StopTime] <= #time(22, 29, 59) then "B/S"
else if [StopTime] >= #time(7, 0, 0) and [StopTime] <= #time(14, 59, 59) then "E/S" else "Help"),
#"Filtered Rows" = Table.SelectRows(Conditions, each ([WorkCentre] <> "Diversion" and [WorkCentre] <> "Insp Divs" and [WorkCentre] <> "Inspection" and [WorkCentre] <> "NDT"))
in
#"Filtered Rows"
This is a real life manufacturing issue that i have reporting out data. The data I report out is Booked Hours (Someone books on a job and off a job, is equal to a booking in hours), over a 3 shift period, starting Sunday Night Shift (N/S) and finishing Friday Back Shift (B/S). I then use the data to create the shown Pivot Table.
The code works fine, and generates the data shown in the table below.
Night Shift (N/S) - Starts on Sunday at 22:30 and finishes on Monday at 07:00......the next Night Shift is Monday at 22:30 and finishes on Tuesday at 07:00........and so on until it finishes on Friday at 07:00
Early Shift (E/S) - Starts on Monday at 07:00 and finishes at 15:00..........Monday to Friday
Back Shift (B/S) - Starts on Monday at 15:00 and finishes at 22:30..........Monday to Friday
The issue i have is that the Pivot Table is based on the Table below, and the Table doesnt show N/S correctly as the days overlap. E/S and B/S are perfect as the sum of booked hours is based on the same day. What i want to show on the Pivot Table is all the booked hours for Sunday N/S, Monday N/S, Tuesday N/S, Wednesday N/S & Thursday N/S. The current way it shows, is some of Sunday N/S (22:30 to 23:59) is captured on the Pivot table as Sunday N/S, however the rest of the Sunday N/S between 00:00 and 07:00 is shown under Monday N/S......along with Monday (N/S 22:30 to 23:59)
I hope i have explained this correctly and sorry for the long winded explanation
let
Source = Excel.CurrentWorkbook(){[Name="fLabourReport"]}[Content],
DT = Table.TransformColumnTypes(Source,{{"StartTime", type datetime}, {"StopTime", type datetime}}),
DayName = Table.AddColumn(DT, "Day Name", each Date.DayOfWeekName([StartTime]), type text),
Time = Table.TransformColumnTypes(DayName,{{"StopTime", type time}}),
Conditions = Table.AddColumn(Time, "Shift",
each if [StopTime] >= #time(22, 30, 0) or [StopTime] <= #time(6, 59, 59) then "N/S"
else if [StopTime] >= #time(15, 0, 0) and [StopTime] <= #time(22, 29, 59) then "B/S"
else if [StopTime] >= #time(7, 0, 0) and [StopTime] <= #time(14, 59, 59) then "E/S" else "Help"),
#"Filtered Rows" = Table.SelectRows(Conditions, each ([WorkCentre] <> "Diversion" and [WorkCentre] <> "Insp Divs" and [WorkCentre] <> "Inspection" and [WorkCentre] <> "NDT"))
in
#"Filtered Rows"