In this article
Add a date filter to reports with customizable periods such as days, weeks, months, and years. A code snippet creates a filter in the toolbar.
The following offers a collection of frequently utilized date filters, allowing report viewers to effortlessly filter their report data for the preferred time period. They can select from five basic periods, including Days, Weeks, Months, Quarters and Years, and even define a custom filter if desired.
The code to create a date filter in a report is:
layoutArea toolbar {
filter date #newdatefilter{
label: "Date" //Filter name
dateVariables: survey:interview_start
}This places a Date filter in the filter block (accessible to the report viewer by clicking the Filter icon), with default settings. The report viewer clicks on the filter to set it up as required.
The Date filter in the Filter block
Forsta Go App
Forsta Go app supports all Date Filter configurations available
Date Filter in Forsta Go
Customizing Filter Options
Dashboard designers can customize filter menus, including hiding options or pinning frequent ones at the top with filter groups and quick-access filters.
Dashboard designers possess a variety of customization options, including the ability to hide some of the default options or pin frequently used filtering periods to the top of the menu through custom expressions.
To conceal some of the standard options, specify the available options using the "filterGroups" property by separating them with commas, as demonstrated in the example.
filterGroups: days,weeks,months }
If you anticipate that report viewers will frequently require a specific time range, you can create a "quick access" filter and attach it above the primary set of options. The code below adds a "Last 2 Quarters" option to the list.
dateOption InQuarter {
label: "Last 2" quarters
start: -2
end: 0
}Customizing Time Periods
CDL reports offer Quick Filter with preset options and Custom Filter where viewers can input specific date ranges using a calendar.
Quick Filter
Each basic period presents several options appropriate to that period for the report viewer to choose from. Some of these options enable the viewer to select or input specific values. For instance, the Months filter enables the viewer to choose a specific calendar month for a specific year, the current month, or a specified number of months up to the current date.
Note
The report viewer can only select one option from the available options.
Custom Filter
The Custom Filter enables the report viewer to designate a specific date range. To open the calendar and choose the appropriate dates, they should click on the "From" and "To" fields. To select the month and year, they can click on Month/Year in each calendar.
For details of the properties and settings, refer to filter in the CDL Reference Guide.
Redefining Date Variables in Widgets and Pages
Users filter data by time periods, redefining date variables for pages and widgets to display chart based on responses and response rates.
In certain widgets and scenarios, a user may need to select a filter time period that applies to different date fields in the data when presenting results. A typical example is when reporting on response rates along with survey data. For instance, if the user selects to view data from the last three months, they may want to display a chart based on the results collected during the last three months and also those who responded to survey invitations within that period. The responses will be based on the "interview_start" variable from the survey response data, while the response rate will be based on when the survey invite was sent, as indicated by the "FirstMailedDate" in the respondent table.
Therefore, it becomes possible to redefine date variables for a specific page.
page #MyPage {
label: "some page"
overrideFilter date {
name: newdatefilter
dateVariables: survey:FirstMailedDate
}
...It is also feasible to redefine variables for a specific widget.
widget contactList {
exportable: true
label: "Contacts"
table: survey:
size: large
sortOrder: descending
sortColumn: d
navigateTo: "Contactspage"
overrideFilter date {
name: newdatefilter
dateVariables: survey:FirstMailedDate
}
...Overriding Date Variables
The date variable for date filter can be overridden using the "override syntax" at the widget level.
It becomes possible to override the date variable to which the date filter applies, enabling improved reporting on response rate data. To achieve this at the widget level, one can use an "override syntax" in any widget where they want to use a different date for the date filter's period selection.
For instance, if the date filter is configured to filter all data based on "Interview_start".
filter date #dateFilter {
label: "Date Filter"
dateVariables: survey:interview_start
}Then on the response rate widget, one can override this with the mailing date.
widget responseRate #rate {
size: small
label: "Response Rate"
overrideFilter date {
name: dateFilter
dateVariables:respondent:createddate
}Then one can observe the same numbers for a period in Studio, using the fasttrack data as an example.
In Studio:
Example of the data in Studio
Setting a Default Date Variable
By default, the date used when using datePeriod in the report is interview_start. You can use dateVariable to change this default to another date variable. For example:
dateVariable #responseDateVariable
{ value: :interview_end
}