Forum Discussion

Dicken's avatar
Dicken
Post Prodigy
1 year ago
Solved

Table Contains syntax explanation

   An example of Table.Contains has the following     Table.Contains( Table.FromRecords( { [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 2, Name = "Jim", ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    It's so that you can match on the name value in a specific record, whatever that name value might be--it might not always be "Bob". So if you have a list of records, which is what a table is, and you want to check if another table contains the name that is in the current row/record. This is especially useful when you have a column of nested tables, so if you have a "Name" column in your table, and you have a column of nested tables that also have a "Name" column, and you want to keep rows where "Name" matches the "Name" in the nested table. So 

     

    each Table.Contains([NestedTableColumnName, _, "Name")

     

    --Nate

  • PwerQueryKees's avatar
    1 year ago

    Good question. As the official documentation tells us the third parameter should be a comparere function, not a string....

    I do see why you would want to name a column (is a list of columns also supported??) to limit the comparison to if the record for the first parameter comes from another table, because it saves a Table.SelectColumns(). At least a convenience and possible a perfromance advantage.