Filtering is a fundamental step in data analysis. This document describes various methods for filtering chart data by date, as well as the display options for the date filter control.
How to filter chart data by date?
Step 1: Drag the date field into the "Filter" area and click the field name to open the settings panel.
Step 2: In the left sidebar, select filter mode. The default mode is "Dynamic date".
Step 3: Select the filter criteria.
If you do not need to display the filter control on the chart, simply click "OK" after completing the settings. To display the date filter on the page, check the "As filter" checkbox in the lower left corner of the panel during setup, then click "OK".
The filter supports configuring the filter control to be displayed on the chart, allowing quick switching of filter criteria during queries. To display the date filter on the page, check the "As time range filter" checkbox in the lower left corner of the panel when configuring the date filter.
As shown below:
You can switch the date filter granularity in the upper left corner of the date filter popup. Supported granularities: year-month-day, year-month, and year-week.
The date range generated based on a user-defined anchor point will change over time. For example, view the order volume for the "last 30 days".
The product provides several preset quick options based on business scenarios, allowing users to quickly specify filter criteria.
Quick options | Definition | Example | Note |
|---|---|---|---|
Past hour | Count back 1 hour from now | This option is only available for partition fields in hour-level synchronized datasets. | |
Past day | Most recent partition date | This option is only available for partition date fields. | |
Past 7 days | Most recent 7 partition dates | This option is only available for partition date fields. | |
Past 14 days | Most recent 14 partition dates | This option is only available for partition date fields. | |
Past 30 days | Most recent 30 partition dates | This option is only available for partition date fields. | |
Last day | Yesterday | If today is 2020-02-13, then the last day = 2020-02-12 | |
Last 7 days | The 7 days ending yesterday | If today is 2020-02-13, then the last 7 days = 2020-02-06~2020-02-12 | |
This week | This week | If today is 2023-06-21, then this week = 2023-06-19~2023-06-20 | |
Last week | Last week | If today is 2023-06-21, then last week = 2023-06-12~2023-06-18 | |
Last 14 days | The 14 days ending yesterday | If today is 2020-02-13, then the last 14 days = 2020-01-30~2020-02-12 | |
Last 30 days | The 30 days ending yesterday | If today is 2020-02-13, then the last 30 days = 2020-01-14~2020-02-12 | |
This month | From the first day of this month to yesterday | If today is 2020-02-13, then this month = 2020-02-01~2020-02-12 | |
This bimonth | From the first day of this bimonth to yesterday | If today is 2020-02-13, then this bimonth = 2020-01-01~2020-02-12 | |
Last 3 months | From the first day of the month 2 months ago to yesterday | If today is 2020-02-13, then the last 3 months = 2019-12-01~2020-02-12 | |
Last 6 months | From the first day of the month 5 months ago to yesterday | If today is 2020-02-13, then the last 6 months = 2019-09-01~2020-02-12 | |
Last year / This year | From the first day of this year to yesterday | If today is 2020-02-13, then the last year = 2020-01-01~2020-02-12 | |
Last 2 years | From the first day of last year to yesterday | If today is 2020-02-13, then the last 2 years = 2019-01-01~2020-02-12 | |
Last 365 days | The 365 days ending yesterday | If today is 2020-02-13, then the last 365 days = 2019-02-13~2020-02-12 | |
Last month | From the first day to the last day of last month | If today is 2020-02-13, then last month = 2020-01-01~2020-01-31 | |
Last bimonth | From the first day to the last day of last bimonth | If today is 2020-02-13, then last bimonth = 2019-11-01~2019-12-31 | |
Last year | From the first day to the last day of last year | If today is 2020-02-13, then last year = 2019-01-01~2019-12-31 |
If the above quick options do not meet requirements, users can also customize dynamic dates.
Note: If you set "workdays" in "Advanced settings", when filtering for the most recent days, the time preview may display preview information that includes rest days. However, in the actual chart, rest days will not appear in the chart. The time preview is for reference only.
In custom scenarios, if the operator is "recent", the product additionally provides checkboxes to adjust the time window granularity for the date range. For a date with "hour, minute, and second", when selecting the granularity as "hour", two checkboxes will appear:
Compared to dynamic dates, a fixed date range does not change over time. For example, if today is 2020-02-13, set the date filter condition to a fixed date: 2020-02-08 to 2020-02-12. Ten days later, the filter condition remains 2020-02-08 to 2020-02-12. When the date field includes hour, minute, and second, an exact time can be selected.
For partitioned date fields, there will be unselectable dates in the calendar, indicating that this date partition does not exist in the dataset.
Configure the start and end times of the date filter separately to flexibly define the filter date range. After selection, you can preview it in the time preview.
For example, if today is 2020-02-13, set the date filter condition as follows:
Start time: Fixed 2020-01-04
End time: Dynamic 1 day ago
The date will then be selected as 2020-01-04 to 2020-02-12. One day later, the date will be selected as 2020-01-04 to 2020-02-13, and so on.
Fixed
Select a fixed date as the start or end time of the filter. If the date field is p_date (the dataset partition field), only dates with data present in the partition can be selected.
Dynamic
Dynamically select a time point before or after the current time as the start or end time of the filter.
Unrestricted
When used as the start time, the start time is not restricted, and all time points less than or equal to the end time are selected.
When used as the end time, the end time is not restricted, and all time points greater than or equal to the start time are selected. An unrestricted end time allows the end time to be dynamically set to the most recent time point with available data.
Caution: The start time and end time cannot both be set as unrestricted; at least one time must be specified.
For example, if an event goes live on June 14, and you need to dynamically view event data during the event period (after June 14), you can configure the date filter as follows to achieve the filtering effect of "2023-06-14 ~ present".
For example, to view event data for the first day of each month and the first day of each quarter from June 11, 2024 to June 11, 2025, you can configure the date filter as follows:
Three types of special values can be filtered: empty dates, non-empty dates, and all dates. By default, all dates are selected.
Definition of "single date": Only one day can be selected at a time.
Caution: When the partition date field is used, a "most recent day with data (1 day)/trading day" checkbox is provided below the calendar. This is mutually exclusive with the calendar above.
When the date filter page is set to dynamic date, advanced, special value, or fixed date mode, select the checkbox at the bottom of the panel and click Confirm.
The filter will provide all four modes simultaneously, making it easy to switch between them.
When the date filter page is in single date mode, select the checkbox at the lower left of the panel, then click OK. The filter will provide single date mode.