Date Range Filter Interactions
Use the asDateRange()
serialization function to bind filters based on date ranges. You can create filters using absolute or relative date ranges.
If the input data is a one-dimensional array with two elements:
- And both elements are numbers, CRM Analytics assumes the numbers are epoch times.
[1016504910000, 1016504910000]
results infieldName in [dateRange([2002,3,19], [2010,8,12])]
. - Otherwise, the first element is used as the minimum and the second element is used as the maximum.
["current day", "1 month ahead"]
results infieldName in ["current day".."1 month ahead"]
. If one of the elements is null, the date range is open-ended.["1 month ago", null]
results infieldName in ["1 month ago"..]
.
If the input data is a two-dimensional array where the outer array has two elements:
- And both nested arrays have two elements, CRM Analytics assumes the data is in the relative date array format.
[["year", -2], ["year", 1]]
results infieldName in ["2 years ago".."1 year ahead"]
. - And both nested arrays have 3 elements, the nested arrays are passed to the SAQL
dateRange()
function.[[2015, 2, 1], [2016, 2, 1]]
results infieldName in [dateRange([2015,2,1], [2016,2,1])]
.
If the input data is null
, the result is fieldName in all
, which doesn’t filter anything.
For instance, let’s say you make a selection in a date widget that returns this absolute date range (in epoch format).
You can create a filter using the returned selection data.
After evaluating the binding, CRM Analytics produces this date range filter.
For relative dates, assume that the date widget returns these relative datas based on your selection.
After evaluation, this data range filters results.
Create a custom query with rows for each custom date range. You can specify ranges using absolute or relative dates.
To filter with absolute ranges, the results of the custom query must return absolute dates.
You can create the filter based on the selected value of the source query.
After CRM Analytics evaluates the binding, the filter is as shown.
To filter with relative ranges, the source query results must be as shown.
You can use this binding to create a filter based on the selected value of the source query.
After CRM Analytics evaluates the binding, the filter becomes:
You can also create an open-ended range filter by specifying null as one of the relative date keywords in the source query. The bound filter is as shown.
After CRM Analytics evaluates the binding, the filter becomes:
The SAQL function date_to_epoch()
returns epoch seconds, but date range filters bindings require milliseconds.