Query Parameters
👉 Example Map with Query Parameters
Query parameters in Dekart provide a powerful way to make your maps interactive and dynamic. With query parameters, you can create SQL queries that dynamically adjust based on user input. Below is a detailed guide to understanding and using query parameters in Dekart.
Syntax for Query Parameters
Query parameters are wrapped in double curly braces ({{parameter_name}}
) and can be used in your SQL queries. For example:
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE region = {{region}}
AND subtype = 'region'
In this query:
{{region}}
is a query parameter that the user can set dynamically.- SQL logic adjusts based on the value provided for the parameter.
Setting Default Values
You can define default values for query parameters. This is useful when a user doesn’t provide input for a parameter.
Making Parameters Optional
To make a parameter optional:
- Use SQL logic to handle cases where the parameter is not provided.
- Combine conditions in your query to handle “all data” when a parameter is empty.
For instance: Example:
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE (
({{region}} = 'ALL' AND country = 'FR')
OR region = 'FR-' || {{region}}
)
AND subtype = 'region'
- The default value
'ALL'
ensures that if no value is entered, all regions are shown.
Sharing Reports with Query Parameters
When you share a report with query parameters, the parameters are included in the URL. This allows you to share a report with specific parameters set.
User with Editor and Admin roles, who have access to update the report, can change the query parameters and see the updated results.
Viewers can view only cached results with the parameters set by the report owner.