While Displayr already has mechanisms for putting date controls on pages, in this article you will see how to do so without having to write any code.
Requirements
- A data set with a Date variable.
- If you don't have a date variable in your data set, you can create one from a categorical variable. See: How to Create a Date Variable from a Categorical Variable Using JavaScript
- Outputs in the Report tree that use raw data that you want to filter.
Method
- Select the output(s) you want to filter.
- Then, from the toolbar, go to the Anything
> Filter > Control > Date Filters on Output. Any date variables in your document will be displayed for you to choose from.
- Choose the date variable you want to use in the filter and click OK
- If you select any outputs that can't take filters, the message below will pop up. Click OK to clear the message. You may need to take alternate steps to filter the items that can't accept filters directly, such as filtering their source data instead:
Displayr will create a new filter variable in the Data Sources tree and apply it to all of the outputs you selected in step 1:
To add the filter to other outputs, select the filter in the Data > Filters & Weight > Filter(s) menu for each output.
The automation also adds two date selection boxes at the top left of the page:
Changing the date range
To change the date range, which changes the data included in the filter, do the following:
- Click on either the From or To box or both boxes depending on which date you want to change.
- Select the desired start and/or end date from the calendar that pops up. In this example, I chose January 1, 2016 as my start date.
Please note that currently the date controls only accept dates formatted as YYYY-MM-DD. If you'd like to suggest alternative date formats, please email our support team: support@displayr.com