Forum Discussion
Employee Shift Grouping
- 6 years ago
Hello CoreyB76
you can add new column to check if an ID was split or was split. WIth this parameter you can filter your table (not splitted canceled) and make the check >16 only on rows that were not splitted. Here a practicable example
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjG0MDWzVNJRAiJDAz0DQz0jAyMDICe4tDgxT8E5sSg1PbMstQgo4pSfpOCcn1dcmgvm+nqBtJgDCefEvOTUnNQUpVgdiIGWZkBRuMnkGAtS6lhQUJRfhmysObqxRqQZa47VVEtThPeNYQa6pCYlVaIY6JWfkYdiYgBIjwV2I5FC1JxUI0F6A1LzUjLz0pViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Punch ID" = _t, #"Reference Punch ID" = _t, #"Date Of Service" = _t, Employee = _t, Client = _t, #"Cost Center" = _t, Hours = _t, Status = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Punch ID", Int64.Type}, {"Reference Punch ID", Int64.Type}, {"Date Of Service", Int64.Type}, {"Employee", type text}, {"Client", type text}, {"Cost Center", type text}, {"Hours", Int64.Type}, {"Status", type text}}), AddIsSplit = Table.AddColumn ( #"Changed Type", "IsSplit", each List.Contains(#"Changed Type"[Reference Punch ID], [Punch ID]), type logical ), FilterCancelNotSplitted = Table.SelectRows ( AddIsSplit, each not ([Status]="Canceled" and [IsSplit]=false) ), AddWasSplit = Table.AddColumn ( FilterCancelNotSplitted, "WasSplit", each List.Contains(AddIsSplit[Punch ID], [Reference Punch ID]), type logical ), Over16 = Table.AddColumn ( AddWasSplit, "Over16", each if [WasSplit]= false and [Hours]>16 then true else false, type logical ) in Over16Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello CoreyB76
you can add new column to check if an ID was split or was split. WIth this parameter you can filter your table (not splitted canceled) and make the check >16 only on rows that were not splitted. Here a practicable example
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjG0MDWzVNJRAiJDAz0DQz0jAyMDICe4tDgxT8E5sSg1PbMstQgo4pSfpOCcn1dcmgvm+nqBtJgDCefEvOTUnNQUpVgdiIGWZkBRuMnkGAtS6lhQUJRfhmysObqxRqQZa47VVEtThPeNYQa6pCYlVaIY6JWfkYdiYgBIjwV2I5FC1JxUI0F6A1LzUjLz0pViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Punch ID" = _t, #"Reference Punch ID" = _t, #"Date Of Service" = _t, Employee = _t, Client = _t, #"Cost Center" = _t, Hours = _t, Status = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Punch ID", Int64.Type}, {"Reference Punch ID", Int64.Type}, {"Date Of Service", Int64.Type}, {"Employee", type text}, {"Client", type text}, {"Cost Center", type text}, {"Hours", Int64.Type}, {"Status", type text}}),
AddIsSplit = Table.AddColumn
(
#"Changed Type",
"IsSplit",
each List.Contains(#"Changed Type"[Reference Punch ID], [Punch ID]),
type logical
),
FilterCancelNotSplitted = Table.SelectRows
(
AddIsSplit,
each not ([Status]="Canceled" and [IsSplit]=false)
),
AddWasSplit = Table.AddColumn
(
FilterCancelNotSplitted,
"WasSplit",
each List.Contains(AddIsSplit[Punch ID], [Reference Punch ID]),
type logical
),
Over16 = Table.AddColumn
(
AddWasSplit,
"Over16",
each if [WasSplit]= false and [Hours]>16 then true else false,
type logical
)
in
Over16
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy