Table.ContainsAny Function in Power Query
The Table.ContainsAny function determines whether any of the specified records appear as rows in the table. An optional parameter equationCriteria may be specified to control comparison between the rows of the table. If no comparison criteria is specified all the columns in the record are checked in the table.
Syntax
Table.ContainsAny(table as table, rows as list, optional equationCriteria as any) as logical
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company = "TCS"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company = "TCS"], [CustomerID = 3, Name = "Alia", Phone = "543-7890", Company = "TCS"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company = "TCS"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864", Company = "TCS"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company = "TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company = "TCS"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864", Company = "TCS"] } ), return = Table.ContainsAny( MyTable, { [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company = "TCS"], [CustomerID = 3, Name = "Diksha", Phone = "543-7890", Company = "TCS"] } ) in return
The output of the above code is true.
Example: Comparing only the “Name” column.
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company = "TCS"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company = "TCS"], [CustomerID = 3, Name = "Alia", Phone = "543-7890", Company = "TCS"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company = "TCS"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864", Company = "TCS"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company = "TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company = "TCS"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864", Company = "TCS"] } ), return = Table.ContainsAny( MyTable, { [CustomerID = 6, Name = "Katrina", Phone = "987-6543", Company = "Microsoft"], [CustomerID = 2, Name = "Diksha", Phone = "543-7890", Company = "TCS"] }, "Name" ) in return
The output of the above code is true.