Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
msmays5
Helper II
Helper II

Table of Lists - Are all List Values in Another List

Hi all, I have a table that contains many fields, one of which is List of Orders. This contains a list, where each value is an order. So for example:

msmays5_0-1600373522904.png

 

And the lists might look like

List 1: {"A", "B"}

List 2: {"C"}

List 3: {"A", "B", "D"}

List 4: {"A", "B", "E"}

List 5: {"C", "D"}

 

I'd like to add a column [Resubmitted Orders] that says, for each list in [List of Orders], determine if ALL the orders in that list are in another single list. So for the above, List 1 and List 2 would both be TRUE because all of the values in List 1 are in List 3/List 4, and all of the values in List 2 are in List 5.

 

Thanks in advance for all of your help!

 

 

1 ACCEPTED SOLUTION
msmays5
Helper II
Helper II

Looks like I was able to figure this one out myself 🙂

 

AddNewest = 
        Table.AddColumn(#"Reordered Columns", "Duplicated Orders", each
            let
                FocusList = [List of Orders],
                FocusID = [Refresh ID],
                ExcludeRow = Table.SelectRows(#"Reordered Columns", each [Refresh ID] <> FocusID),
                ListOfLists = ExcludeRow[List of Orders],
                TableOfLists = 
                    Table.AddColumn(
                        Table.FromList(ListOfLists, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
                        "Match", 
                        each List.ContainsAll([Column1], FocusList),
                        type logical
                    )
            in
                TableOfLists
        ),
    
    #"Added Custom2" = Table.AddColumn(AddNewest, "Duplicates", each 
        Table.RowCount(Table.SelectRows([Duplicated Orders], each [Match] = true))),

    #"Filtered Rows2" = Table.SelectRows(#"Added Custom2", each ([Duplicates] = 0)),
    #"Removed Columns2" = Table.RemoveColumns(#"Filtered Rows2",{"Duplicated Orders", "Duplicates", "List of Orders"})
in
    #"Removed Columns2"

View solution in original post

1 REPLY 1
msmays5
Helper II
Helper II

Looks like I was able to figure this one out myself 🙂

 

AddNewest = 
        Table.AddColumn(#"Reordered Columns", "Duplicated Orders", each
            let
                FocusList = [List of Orders],
                FocusID = [Refresh ID],
                ExcludeRow = Table.SelectRows(#"Reordered Columns", each [Refresh ID] <> FocusID),
                ListOfLists = ExcludeRow[List of Orders],
                TableOfLists = 
                    Table.AddColumn(
                        Table.FromList(ListOfLists, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
                        "Match", 
                        each List.ContainsAll([Column1], FocusList),
                        type logical
                    )
            in
                TableOfLists
        ),
    
    #"Added Custom2" = Table.AddColumn(AddNewest, "Duplicates", each 
        Table.RowCount(Table.SelectRows([Duplicated Orders], each [Match] = true))),

    #"Filtered Rows2" = Table.SelectRows(#"Added Custom2", each ([Duplicates] = 0)),
    #"Removed Columns2" = Table.RemoveColumns(#"Filtered Rows2",{"Duplicated Orders", "Duplicates", "List of Orders"})
in
    #"Removed Columns2"

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors