Query filters allow you to restrict which data from a data view certain users will be able to access.
For example, if you had a data view containing a Region
field, you could write query filters that restricted access based on the value of the Region
field.
For example, a Northern region query filter could be assigned to a Northern region environment group and could have the following filter expression:
Region = 'Northern'
Likewise, a Southern region query filter could be assigned to a Southern region environment group, with the following filter expression:
Region = 'Southern'
With these query filters set in place, when users within the Northern environment group queried the data view, they would only see records where the value of the Region field was 'Northern'. Similarly, users within the Southern environment group would only see records where the value of the Region field was 'Southern'.
If Allow user to view all data when there are query filters but no matching query filter is found for a user is not selected, users who were not in either the Northern or Southern environment group would not see anything when querying the data view. If this option is selected, users who were not in either the Northern or Southern environment group would see all data.
When are query filters applied?
Query filters are applied whenever a data view is used to build a dashboard.
Using profile fields with query filters
If a data set contains a large number of values by which you want to filter, you can avoid writing a separate query filter for each one by using profile fields.
Profile fields are values that can be attached to user accounts by your Administrator, and they can be constructed to match the values in a data set.
For example, a set of user accounts could have a State
profile field attached to them, with a value of 'IL', 'WI', 'FL', or some comma delimited combination of these values depending on the user.
Within a single query filter, you could then use the PROFILE_FIELD()
function in an expression that checks whether one of the profile field values of a user matches the value of a specific field within the data view.
For example, for a data view with a state
field, you could use the following filter expression:
state = PROFILE_FIELD('State')
This would ensure that users within the environment group assigned to this query filter would only be able to see records where one of the values of their State
profile field matched the value of a record's state
field.
Using multiple query filters
When multiple query filters are applied, the query filters are treated in an OR-like fashion. That is, each query filter is considered independently.
For example, if you had the following expressions being used as query filters:
-
field1 > 0
-
field2 < 100
Values such as -1 or 101 would both make it through the query filters.
To get an AND effect, you would need to combine these expressions into a single query filter.