List.Contains Function in Power Query
The List.Contains function returns true if a value is found in a list, otherwise false. An optional equation criteria value, equationCriteria, can be specified to control equality testing.
Syntax
List.Contains(list as list, value as any, optional equationCriteria as any) as logical
Example: Find the given value in the input list. If it is there then the function returns true otherwise false.
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England", "China"}, return = List.Contains(source, "Canada") in return
The output of the above code is true.
Example:
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England", "China"}, return = List.Contains(source, {"Canada"}) in return
The output of the above code is false. Because here we are finding the item which should be a list and contains value “Canada”, not a simple text value “Canada”.
Example:
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England", "China"}, return = List.Contains(source, "canada") in return
The output of the above code is false.
Example:
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England", "China"}, return = List.Contains(source, "canada", Comparer.OrdinalIgnoreCase) in return
The output of the above code is true.