Filtering is a way to control the end results of your query. All the fields available to you in a data source can be used in a filter. A filter is built by choosing the field to filter by, choosing the logical operator and then entering a value to filter by.
This guide will walk you through how to build and create filters for your Supermetrics queries.
Create a filter
- Open the Supermetrics sidebar.
- Create a new query or select an existing query to modify.
- Go to the Filter section.
- Click Add filter to start the creation process.
- Select the field you wish to filter by from the Field dropdown menu. Then, choose the operator to function by, and enter your filter string. Learn more about operators below.
- Once you’re happy with the filter, click Update query to run the query with the filter.
Dynamic cell references
You can also use cell references as values for your filter — learn how in our guide.
Add multiple filters to one query
You can add multiple filters to a single query. You should create the filters before doing this, so they can be added to the query in the order you need them to be.
- In the Filter section of the Supermetrics sidebar, click Add filter (or the plus icon) next to the filter you want to add to the query.
- Choose AND or OR.
- AND means results must match all filters in order to be either included or excluded.
- OR means that results can match any filter in the query in order to be either included or excluded.
Modify or remove a filter
You can make changes to your filters by modifying the query on the sidebar, or remove them by clicking the trashcan icon next to the filter, then clicking Update query.
About operators
When creating strings that include any of these operators, please note that some ignore a word’s capitalization while some don’t.
Equals, Does not equal, Contains, and Does not contain ignore a word’s case, so “TOFU 2020” and “tofu 2020” would show the same results.
However, Matches regex and Does not match regex filter values based on the string’s case, so when using either of these operators, “TOFU 2020” and “tofu 2020” would return different results.
Does not equal is the direct opposite of Equals. This operator will leave out matching results.
Letter case is irrelevant in Does not equal (so “TOFU 2020” and “tofu 2020” would return the same results).
The Matches regex operator takes the regular expression string you enter into the value field and compares it to the results, leaving in the results that match your regex string.
There are many resources available to learn more about regular expressions. For example, RegexOne offers a simple tutorial with interactive exercises.
Troubleshooting
If you’re having trouble getting your filter to work properly, check these settings.
Whitespace
An extra whitespace (a space between letters, numbers, or words, sometimes left at the beginning or end of a string) can stop a filter from reading the value field string properly. Check for extra whitespaces and remove them.
Old fields
Sometimes, a filter set up in the past can contain fields that aren’t supported any longer. Check our field list to make sure your filter’s fields are still valid.