BMC Helix Dashboards - How to parse a "Date Range" variable on a Dashboard - INCLUDES VIDEO
Knowledge Article
BMC Helix Dashboards - How to parse a "Date Range" variable on a Dashboard - INCLUDES VIDEO
How to parse a "Date Range" variable on a Dashboard
BMC Helix ITSM
Helix Dashboards (Grafana Reporting)
22.x
BMC Helix ITSM
Helix Dashboards (Grafana Reporting)
22.x
How to parse a "Date Range" variable on a Dashboard? How to use variables as date filters?
When more than one date picker is required in a Dashboard to filter by more criteria, e.g. filter by "Submit date" and also by "Resolved date", it is possible to create variables of type "Date Range" and add it to the query as follows:
1. Within the Dashboard, go to the Dashboard settings:
2. From the left menu, click on the Variables option and then click on the Add Variable button:
3. Create the variable type "Date Range" and save the changes:
4. When returning to the Dashboard, an additional date picker will be displayed on the top left side:
5. In order to make this variable considered by the SQL query, it's necessary to add the following syntax in the SQL Editor between '${date1:from}' and '${date1:to}'where date1 is the name of the variable created as follows:
SELECT DISTINCT
`HPD:Help Desk`.`Incident Number`,
`HPD:Help Desk`.`Submit Date`,
`HPD:Help Desk`.`Last Resolved Date`
FROM
`AR System Schema`.`HPD:Help Desk`
WHERE
(`HPD:Help Desk`.`Submit Date` >= $__from/1000 and `HPD:Help Desk`.`Submit Date` <= $__to/1000) and
`HPD:Help Desk`.`Last Resolved Date` between '${date1:from}' and '${date1:to}'
Note, the following statement can be used if the Between is not working: -- `HPD:Help Desk`.`Last Resolved Date` >= '${date1:from}' and `HPD:Help Desk`.`Last Resolved Date` <= '${date1:to}'
The above green text indicates the syntax of the default date picker, and the blue text indicates the syntax of the secondary date picker:
Final result:
Note. If, instead of a TIMESTAMP field, a DATE field is used with the Date Range Variable, it is necessary to convert this DATE field using the DATE() function as follows: