Forum Discussion

MarkCBB's avatar
MarkCBB
Helper V
10 years ago
Solved

Items not found

Hi there,   I have 3 tables: Product (ProductID, Product Name) Stores (StoreID, Sotre Name) Sales (Fact Table)   I need to create a list that contains Products that are not in a store, the fac...
  • ImkeF's avatar
    ImkeF
    10 years ago

    It does the right thing, just that you need to connect the code to your tables. Either like this:

     

    let
        Sales = SALES,
        Product = P,
        Store = S,
        Partition = Table.Group(Sales, {"StoreID"}, {{"Partition", each Table.NestedJoin(_,{"ProductID"},Product,{"Product​ID"},"NewColumn",JoinKind.RightAnti)}}),
        #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"NewColumn"}, {"NewColumn"}),
        #"Expanded NewColumn" = Table.ExpandTableColumn(#"Expanded Partition", "NewColumn", {"ProductID"}, {"ProductID"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded NewColumn", each ([ProductID] <> null))
    in
        #"Filtered Rows"

     

    or directly:

    let
        Partition = Table.Group(SALES, {"StoreID"}, {{"Partition", each Table.NestedJoin(_,{"ProductID"},P,{"ProductID"},"NewColumn",JoinKind.RightAnti)}}),
        #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"NewColumn"}, {"NewColumn"}),
        #"Expanded NewColumn" = Table.ExpandTableColumn(#"Expanded Partition", "NewColumn", {"ProductID"}, {"ProductID"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded NewColumn", each ([ProductID] <> null))
    in
        #"Filtered Rows"