Skip to Content

Metrics

Add a complex filter

Filter a metric's rows with your own SQL condition, and save it to use again.

Filter a metric’s rows with your own SQL condition, and save it to use again.

Before you start

  • The metric is open in the builder and has at least one field. Create a metric

Steps

  1. Select Filters.

  2. Select Add Filter, then Complex Filter.

    Filters panel with the Add Filter menu open and Complex Filter highlighted.
    Complex Filter is the second item under Add Filter.
  3. In Filter Name, enter a name, for example Paid orders.

    Complex filter card with Online sales only typed in the highlighted Filter Name field.
    Name the filter on the Write SQL tab.
  4. On the Write SQL tab, write the condition in Filter expression, for example "public_orders"."status" = 'paid'.

    Complex filter card with the Filter expression editor highlighted, holding the condition sales channel equals Online.
    Write the SQL condition in Filter expression.
  5. Select Save Filter to keep it for later. This step is optional.

    Complex filter card with the Save Filter button highlighted next to Format query.
    Save Filter keeps the condition for later use.
  6. Select Done.

The preview updates with only the matching rows.

Write the condition

  • Write only the condition, as you would after WHERE. Do not write WHERE, SELECT or ORDER BY.
  • Reference columns as schemaName_tableName.columnName. For a SQL result or custom table, use tableName.columnName.
  • You can use AND, OR and functions of your database, for example "public_orders"."amount" > 100 AND "public_orders"."region" IN ('EU', 'US').
  • Format query tidies the SQL.

Use a saved filter

  1. Select Add Filter, then Complex Filter.

  2. Select the Saved Filters tab.

    Complex filter card with the Saved Filters tab highlighted next to Write SQL.
    Saved Filters is the second tab on the card.
  3. In Select a saved filter, pick the filter.

  4. Select Done.

To delete a saved filter, select the delete icon next to it and confirm.

For a filter your viewers pick from on the dashboard, use a metric filter.

If something goes wrong

  • please add valid where condition. Remove WHERE, SELECT or ORDER BY, and write one condition only.
  • Save Filter is greyed out. Enter both a Filter Name and a condition.
  • Complete this filter to add another. Finish the current filter first.