Forum Discussion
Applicable88
3 years agoImpactful Individual
Combine table with missing records
Hello, I have a mastercalendar and a facttable. The mastercalendar consist of all dates I need and also icludes a "Productive" indicator to show if a day is a working day or not. In the facttable I ...
- 3 years ago
Hi Applicable88,
Please try this:
let Mastercalendar = let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzTUMzIwMlLSUTIEYUOlWB2guCV2cUMDHOKGOMSNkMQNkMSNcYib4DDHFIe4GRbxWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Productive = _t, Month = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Productive", Int64.Type}, {"Month", Int64.Type}}) in #"Changed Type", Facttable = let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk8szsjMS1fSUbLQNzTUNzIwMlKK1YlWcs5JTczDJhGWmFxamotPvSWKBMICQwPsBqGJI2kwQ0jEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Task = _t, Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task", type text}, {"Date", type date}}) in #"Changed Type", allTask = List.Distinct(Facttable[Task]), FirstFilterAllProductive = Table.SelectRows(Mastercalendar, each [Productive] = 1), AddTasks = Table.NestedJoin(FirstFilterAllProductive, {"Date"}, Facttable, {"Date"}, "Tasks", JoinKind.LeftOuter), #"Expanded Tasks" = Table.ExpandTableColumn(AddTasks, "Tasks", {"Task", "Date"}, {"Task", "Date.1"}), #"Grouped Rows" = Table.Group(#"Expanded Tasks", {"Date"}, {{"Completed", each List.ContainsAll(_[Task], allTask), Logical.Type}, {"MissedList", each List.RemoveItems(allTask, _[Task]), type list}, {"MissedText", each Text.Combine(List.RemoveItems(allTask, _[Task]), ", "), type text}}) in #"Grouped Rows"Cheers,
John
jbwtp
3 years agoMemorable Member
Hi Applicable88,
Please try this:
let
Mastercalendar =
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzTUMzIwMlLSUTIEYUOlWB2guCV2cUMDHOKGOMSNkMQNkMSNcYib4DDHFIe4GRbxWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Productive = _t, Month = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Productive", Int64.Type}, {"Month", Int64.Type}})
in
#"Changed Type",
Facttable =
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk8szsjMS1fSUbLQNzTUNzIwMlKK1YlWcs5JTczDJhGWmFxamotPvSWKBMICQwPsBqGJI2kwQ0jEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Task = _t, Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Task", type text}, {"Date", type date}})
in
#"Changed Type",
allTask = List.Distinct(Facttable[Task]),
FirstFilterAllProductive = Table.SelectRows(Mastercalendar, each [Productive] = 1),
AddTasks = Table.NestedJoin(FirstFilterAllProductive, {"Date"}, Facttable, {"Date"}, "Tasks", JoinKind.LeftOuter),
#"Expanded Tasks" = Table.ExpandTableColumn(AddTasks, "Tasks", {"Task", "Date"}, {"Task", "Date.1"}),
#"Grouped Rows" = Table.Group(#"Expanded Tasks", {"Date"}, {{"Completed", each List.ContainsAll(_[Task], allTask), Logical.Type}, {"MissedList", each List.RemoveItems(allTask, _[Task]), type list}, {"MissedText", each Text.Combine(List.RemoveItems(allTask, _[Task]), ", "), type text}})
in #"Grouped Rows"
Cheers,
John