Forum Discussion

cheryl-lee33's avatar
cheryl-lee33
Icon for Helper I rankHelper I
6 years ago
Solved

How to use list.contains from another query

Hi, I have two queries: one query (source 1) has data field called "Local Authorities" and record count, and the other query (source 2) has the data of "local authority group" and "local authority"....
  • edhans's avatar
    6 years ago

    Hi cheryl-lee33 

     

    The problem is once you use the List.Contains, you are limited in scope as to what it can see. You need to assign your values you want compared to a variable first. So something like this, as viewed in the Advanced Editor:

     

     

     

        #"Add Column" = 
            Table.AddColumn(
                #"Changed Type",
                "New Column",
                each let 
                    varFieldValue = [Local authorities]
                in
                    List.Contains(
                        Table.Column(#"Source 2", "local authority - Group"),
                        varFieldValue
                    )
            )

     

     

     

    This will return a true/false column, which you can then filter.