This page explains how to create dashboards with filters that let you choose the data you want to display.
user_agent_filter
.country_filter
.France
is displayed in the list of options, and the value FR
is used to filter data in your charts. Define the key-value pairs in one of the following ways:
project
command to create key-value fields from any output.tostring()
.geo.country
field to populate the list of options. It projects these values as both the key and the value and sorts them in alphabetical order.
country_filter
.city_filter
. The dependent filter must be a select filter.declare query_parameters
at the beginning of your query to reference the independent filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in your query even though it doesn’t exist in your data. For more information, see Declare query parameters.country_filter
parameter to filter results in the dependent filter’s query.country_filter
to determine the list of options in the dependent filter. Based on the selected country, the APL query uses the distinct values in the geo.city
field to populate the list of options. It projects these values as both the key and the value and sorts them in alphabetical order.
declare query_parameters
at the beginning of the chart’s APL query to reference the filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in the chart’s query even though it doesn’t exist in your data. For more information, see Declare query parameters.
The APL query below defines a statistic chart where the data displayed depends on your choice in the filter with the ID country_filter
. For example, if you choose France in the filter, the chart only displays the number of HTTP requests from this geographical origin.
user_agent
field.declare query_parameters
at the beginning of an APL query to reference a filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in the chart’s query even though it doesn’t exist in your data.
The declare query_parameters
statement defines the data type of the parameter. In the case of filters, the data type is always string.
where
clause. For example, where isempty(country_filter) or ['geo.country'] == country_filter
means that if no option is chosen in the country filter, isempty(country_filter)
is true and the data isn’t filtered. If any other option is chosen with a non-null value, the chart only displays data where the geo.country
field’s value is the same as the value chosen in the filter.