1+ // Using Merge Query
2+ let
3+ Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4tSC0qTk1JTVHSUTKzNDE2BtKGFkqxOrjkTPDImeGRMwLLBaUmplRChU2BNA7TQFKWuKWghmGXw+EIkJyRAaacoZGxCdwhMOdBBYHhEAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, #"Work Item Id" = _t, Week = _t]),
4+
5+ All_Records =
6+ Table.TransformColumnTypes(Source,{{"State", type text},
7+ {"Work Item Id", Int64.Type}, {"Week", Int64.Type}} ),
8+
9+ // depending on the data source, you may need to wrap a step in
10+ // Table.StopFolding() to ensure evaluation at that location
11+
12+ #"Only Ids To Keep" = Table.SelectRows( All_Records,
13+ each 0 <> Comparer.OrdinalIgnoreCase( [State], "superseded") ),
14+
15+ #"Records To Keep" = Table.NestedJoin(
16+ All_Records, {"Work Item Id"},
17+ #"Only Ids To Keep", {"Work Item Id"},
18+ "Joined", JoinKind.Inner),
19+
20+ FinalTable = Table.RemoveColumns( #"Records To Keep", { "Joined" } )
21+
22+ in
23+ FinalTable
24+
25+ // Using Join
26+ let
27+ Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4tSC0qTk1JTVHSUTKzNDE2BtKGFkqxOrjkTPDImeGRMwLLBaUmplRChU2BNA7TQFKWuKWghmGXw+EIkJyRAaacoZGxCdwhMOdBBYHhEAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, #"Work Item Id" = _t, Week = _t]),
28+
29+ All_Records =
30+ Table.TransformColumnTypes(Source,{{"State", type text},
31+ {"Work Item Id", Int64.Type}, {"Week", Int64.Type}} ),
32+
33+ // depending on the data source, you may need to wrap a step in
34+ // Table.StopFolding() to ensure evaluation at that location
35+
36+ #"Only Ids To Keep" = Table.SelectRows( All_Records,
37+ each 0 <> Comparer.OrdinalIgnoreCase( [State], "superseded") ),
38+
39+ // this by itself causes an error because column names collide
40+ // Custom1 = Table.Join( All_Records, "Work Item Id", #"Only Ids To Keep", "Work Item Id", JoinKind.Inner ),
41+
42+ // we only care about one column in this case, so we can rename it, and drop the rest. preventing collisions
43+ #"To Keep Column" = Table.SelectColumns( #"Only Ids To Keep", {"Work Item Id"}, MissingField.Error ),
44+ #"Wanted Ids Column" = Table.RenameColumns( #"To Keep Column", {"Work Item Id", "Wanted Id"} ),
45+
46+ #"Filtered Records" = Table.Join(
47+ All_Records, "Work Item Id", #"Wanted Ids Column", "Wanted Id", JoinKind.Inner ),
48+
49+ #"Removed Columns" = Table.RemoveColumns( #"Filtered Records", { "Wanted Id" })
50+
51+ in
52+ #"Removed Columns"
0 commit comments