Check membership in a table with CONTAINS: did this customer buy a bike?

Test whether a value appears in a virtual table with CONTAINS, and build a yes/no flag per customer that follows the report’s filters.

You will learn to

  • Test whether a table contains a value with CONTAINS
  • Build the table of what actually happened with SUMMARIZE
  • Return a yes/no flag that follows filters

How it works

`CONTAINS(table, column, value)` returns TRUE when at least one row of the table has that value in that column. You can test several columns at once by adding more column/value pairs. The `IN` operator, `"Bikes" IN table`, is the short form for a one-column table.

The question is always: **which table?** In a customer’s row, `VALUES(Product[Category])` still lists all three categories, because the customer filter doesn’t reach Product. You want the categories that appear in that customer’s **sales**.

`SUMMARIZE(Sales, Product[Category])` gives exactly that: the categories found in the visible Sales rows. In a customer’s row, for a chosen year, that’s what they bought.

Practice it hands-on with a real data model and a live report that updates as you type.

Bought in Q4 = IF(CONTAINS(SUMMARIZE(Sales, 'Date'[Quarter]), 'Date'[Quarter], "Q4"), "Yes", "No")