let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ItemId", type text}, {"WarehouseID ", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ItemId"}, {{"AllRows", each _, type table [ItemId=text, #"WarehouseID "=number]}}),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1),
#"Expanded AllRows" = Table.ExpandTableColumn(#"Added Index", "AllRows", {"WarehouseID "}, {"WarehouseID "}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded AllRows", "Find ItemId", each if [#"WarehouseID "] = 20 then [ItemId] else if [#"WarehouseID "] = 50 then [ItemId] else null),
#"Merged Queries" = Table.NestedJoin(#"Added Conditional Column", {"ItemId"}, #"Find ItemId", {"Column1"}, "Find ItemId.1", JoinKind.LeftAnti),
#"Removed Other Columns" = Table.SelectColumns(#"Merged Queries",{"ItemId", "WarehouseID ", "Index"})
in
#"Removed Other Columns"
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ItemId", type text}, {"WarehouseID ", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ItemId"}, {{"AllRows", each _, type table [ItemId=text, #"WarehouseID "=number]}}),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1),
#"Expanded AllRows" = Table.ExpandTableColumn(#"Added Index", "AllRows", {"WarehouseID "}, {"WarehouseID "}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded AllRows", "Find ItemId", each if [#"WarehouseID "] = 20 then [ItemId] else if [#"WarehouseID "] = 50 then [ItemId] else null),
#"Find ItemId1" = #"Added Conditional Column"[Find ItemId],
#"Removed Duplicates" = List.Distinct(#"Find ItemId1"),
#"Converted to Table" = Table.FromList(#"Removed Duplicates", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Filtered Rows" = Table.SelectRows(#"Converted to Table", each ([Column1] <> null))
in
#"Filtered Rows"