Using parameters in Redash
⏱ Время чтения текста – 2 минутыThe most convenient and useful thing in Redash is parameters. Parameters can be both in a report and in dashboards.
Parameter – is an element of the interface, controlled by a user producing a report.
Parameter in a report can be of the following types:
Each type explained separately:
- Text – text input field, can be used in constructions of LIKE type, such parameter can’t be applied in public dashboards
- Number – number, entered by a user
- Dropdown list – list of values, from which a user can select just one or several values (not long ago, an option of multi-entry of parameters in a dropdown list appeared)
- Query dropdown list – similarly to the previous one, however the values will be taken from the existing query results
- Date / Date and Time / Date and Time (with seconds) – fields of date entry
- Date Range / Date and Time Range / Date and Time Range (with seconds) – fields of date ranges entry.
It’s convenient to use for the following construction
between '{{parameter.start}}' and '{{parameter.end}}'
In case of dashboard, a situation might arise, when a parameter is named the same way in several queries, then it will become common for all the dashboard, it’s handy.
One of not obvious, but rather useful solutions: how to make a parameter disabled?
Let’s assume, that parameter of “dropdown list” type is named parameter and we want to set it for a column geo of a table, then the code of the query will look approximately like that:
WHERE
('{{parameter}}' = 'Disabled' or geo = '{{parameter}}')
At that, surely, ‘Disabled’ should be added to the values of the dropdown list.