-
QuestionI am using Perspective for data visualization and working with time series data that includes date columns. I would like to know if Perspective supports range-based filtering for date types. Specifically:
Use CaseI am working with stock price data and sensor time series data, and I need to filter records within specific time periods for analysis. Example# Current filter syntax
filter=[["size", ">", 2]]
# What I hope to achieve for dates
filter=[["Date", "between", "2024-01-01", "2024-06-30"]]
# or
filter=[["Date", ">=", "2024-01-01"], ["Date", "<=", "2024-06-30"]]Any guidance would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The latter example code you've posted already works, e.g. for superstore data you can use a config such as: {
"plugin": "Y Bar",
"group_by": ["Order Date"],
"filter": [
["Order Date", ">=", "2016-12-01"],
["Order Date", "<=", "2017-12-01"]
],
"columns": ["Sales"]
}You can also rewrite your filter as a boolean
{
"plugin": "Y Bar",
"group_by": ["Order Date"],
"split_by": ["Filtered Date"],
"expressions": {
"Filtered Date": "\"Order Date\" > date(2014, 12, 1) and \"Order Date\" < date(2015, 12, 1) \n"
},
"columns": ["Sales"]
} |
Beta Was this translation helpful? Give feedback.

The latter example code you've posted already works, e.g. for superstore data you can use a config such as:
{ "plugin": "Y Bar", "group_by": ["Order Date"], "filter": [ ["Order Date", ">=", "2016-12-01"], ["Order Date", "<=", "2017-12-01"] ], "columns": ["Sales"] }You can also rewrite your filter as a boolean
expressionscolumn and then use this filter predicate in combination with other features, likesplit_by:{ "plugin": "Y Bar", "group_by": ["Order Date"], "split_by": ["Filtered Date"], "expressions": { "Filtered Date": "\"Order Date\" > date(2014, 12, 1) and \"Order Date\" < date(2015, 12, 1) \n" }, "columns": ["Sales