How to use single filter widget in the dashboard to control different time ranges.
For example, we want the date range filter to be set Feb 1- 14, but some visuals to show 2 weeks before (Jan 15-30) and some visuals showing 2 week after (Feb 15-30).
You can do this using custom parameter expressions in the filters of the visuals.
First, remember that all filter widget set parameters, which you can view in the funnel at the top right:
You use any of these parameters in your visualizations using the special syntax:
In this example use-case, we can write a filter expression as such to manipulate the date range we expect:
[order_date_string] between date_sub(cast('<<order_date_string.start>>' as timestamp), interval 2 weeks) and date_add(cast('<<order_date_string.end>>' as timestamp), interval 2 weeks)
You want to enter this expression in the filter shelf element as show below:
Refer to this page for more info around date_add / date_sub functions (https://www.cloudera.com/documentation/enterprise/5-13-x/topics/impala_datetime_functions.html)
NOTE - disable dataset scope
When using custom filter expressions, you want to disable dataset scope filtering especially if the filter widget comes from the same dataset as the visual.
You can do this by enabling “explicit scope” from Settings -> Parameters