Forum Discussion
How to use list.contains from another query
- 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.
You just have to know the syntax cheryl-lee33 which means visiting the MS pages quite often.
Table.Column(table as table, column as text) as list
So it is asking for the column name as a text value, thus "Column Name"
List.Contains(list as list, value as any, optional equationCriteria as any) as logical
It is asking for a value, so you must reference the column with [Column Name] or via the variable which contains the value.
And lots of trial and error. 😀
If you want to dive deep, this is the book to go with IMHO.
edhans Anonymous Thank you! I have taken notes of your input.