Date query

更新时间:
复制 MD 格式

Filter bars allow you to query data based on date fields. This topic describes how to configure a date field in a filter bar.

Prerequisites

  • You have created a dashboard, and its charts contain date fields.

  • An empty filter bar is added to the dashboard. For more information, see Create a filter bar.

Procedure

The following figure shows an example of a configured filter bar.

image

Basic configuration

Display type

The date filter bar supports date selection.

Time granularity

For associated date fields, you can switch the time granularity and select multiple granularity combinations. This feature is supported for all date fields, such as year, quarter, month, week, day, and ymdhms, except for those with hour, hour-minute, or hour-minute-second granularities. See the table below for details:

Date field

Time granularity

year

Defaults to year. Can be switched to year-quarter, year-month, year-week, or year-month-day.

quarter

Defaults to year-quarter. Can be switched to year, year-month, year-week, or year-month-day.

month

Defaults to year-month. Can be switched to year, year-quarter, year-week, or year-month-day.

week

Defaults to year-week. Can be switched to year, year-month, year-quarter, or year-month-day.

day

Defaults to year-month-day. Can be switched to year, year-quarter, year-month, or year-week.

ymdhms

Defaults to year-month-day-hour-minute-second. Can be switched to year, year-quarter, year-month, year-week, or year-month-day.

hour

Defaults to hour. Switching time granularity is not supported.

minute

Defaults to hour-minute. Switching time granularity is not supported.

second

Defaults to hour-minute-second. Switching time granularity is not supported.

Note

You cannot select multiple time granularities in fiscal year scenarios.

Data source

A filter bar's data source can be a Default Date Box or Dataset Fields. When the data source is set to Default Date Box, date cascading is supported. When set to Dataset Fields, it supports same-source, cross-source, and date cascading. For more information, see Configure cascading for a date filter bar.

  • Default Date Box

    This option has no specific data source. It only supports date cascading and does not support cascading with other controls.

    image

  • Dataset Fields

    Select a dataset as the data source. In addition to date cascading, this option supports cascading with dropdown and tree controls.

    image

Time filter range

Set a time range for the query to control the amount of data being filtered. You cannot select dates outside the specified range.

image

    • Interval type defaults to None and supports Start at, Ends at, and Time interval.

      image

    • This example shows how to set a relative time range when the Interval type is Start at.

      image

      Note

      For T, you can select any granularity level within the current time granularity. For example, if the current time granularity is year-month-day, you can select year, month, or day. If the current time granularity is year-month-day-hour-minute-second, you can select year, month, day, hour, minute, or second for T.

      For example, when the time granularity is ymdhms, calculating a relative time offset in seconds can be complex. You can switch the granularity for T to Day to quickly view time data for different dates.

    • This example shows how to set an absolute time range when the Interval type is Start at.

      image

    • If you select Dynamic query time window and set the Max query time range, you can limit the maximum time range for a single query within the overall time filter range.

      image

Filter method

You can choose between single-date and date-range filtering. For configuration details and results, see Single-date query and Date range query.

Default value

You can set a default value using Manual Input or a Dynamic Function.

  • You can use Manual Input to set a default value for relative or absolute time. For more information, see Set time filter range.

    image

  • If data for today or yesterday has not been generated, you cannot accurately select a date using relative or absolute time. In this case, you can use a Dynamic Function to get the latest available date.

    image

    • When the filter method is Single date, you can set the default time to Maximum value of query field, Minimum value of query field, or First item of query field.

      image

    • When the filter method is a Range (such as day range or month range) and the interval type is set to Start at, Ends at, or Time interval, the default time can be set to start or end at the Minimum value of query field or Maximum value of query field.

      Note

      You can set only the Start at or Ends at value. If both the start time and end time are set, the start time cannot be later than the end time.

      image

Quick date switching

When enabled, this adds navigation arrows to the date filter box on the report page for quick date switching.

Note

This option is supported when the time granularity is year, quarter, month, week, or day, and the filter method is a single-granularity date.

When the filter method is set to Single date and the Switch Dates feature is enabled, arrows appear next to the date control on the dashboard. You can click the arrows to quickly switch dates, as shown in the following figure.

箭头切换

    Note

    The navigation arrows are active only when a specific date is selected in the date control.

    If a time filter range is set, you cannot use the arrows to switch to a date outside that range.

Single-date query

This example shows how to display sales data for a specific day using the order date (day) field.

  1. On the Dashboards page, select a dashboard that contains the required chart and filter bar.

    image.png

  2. In the filter bar, click advanced configuration.

  3. In the Query Condition Settings panel, set the query conditions as shown in the following figure.

    image

  4. After you complete the configuration, select a date in the filter conditions and click Query to view the sales data for that day.

    1经验

Date range query

This example shows how to display the profit of a store over a period of time using the order date (day) field.

  1. On the Dashboards page, select a dashboard that contains the required chart and filter bar.

    The dashboard charts must contain a date field.

    image.png

  2. Click Add Standard Control.

  3. In the Query Condition Settings panel, set the query conditions as shown in the following figure.

    image

  4. After you complete the configuration, select a date range in the filter conditions and click Query to view the store's profit for that time period.

    image

    When the filter method is set to a range, you can use the following features to better view your data.

    • Interval type: Supports four types: Start at, Ends at, Time interval, and quick range.

      Start at

      image

      Ends at

      image

      Time interval

      image quick range

      image

    • Customize quick range: Supports various range scenarios, allowing you to customize quick range values. You can select a quick range from the drop-down list or add a custom quick range based on your needs.

      image

      Note

      This option can be configured only when Interval type is set to quick range.

      • You can quickly select a quick range from the drop-down list. The available quick ranges vary depending on the time granularity. For more information, see Query type configuration display.

        image

      • If the built-in quick ranges do not meet your requirements, click Add custom quick range to create a custom configuration.

        Note

        A custom quick range applies only to the current query condition.

        image

        On the custom quick range configuration page, you can configure the following settings.

        image

        Parameter

        Description

        Range name

        The name of the custom range.

        Reference date

        The reference date can be set to Today, Yesterday, or Custom.

        image

        Note

        T represents today. For example, T+1 represents tomorrow, and T-1 represents yesterday.

        The reference date serves as the starting point for defining a date range. After you select a reference date, the system calculates the date range forward or backward from it. For example, if today is October 17, 2025, the reference date is set to "Yesterday" (October 16, 2025), and the date range is set to "Last 3 days", the actual query date range will be from October 14, 2025, to October 16, 2025. image

        Date range

        Note

        You must configure the Date range after you set the reference date.

        • "Last N" date range: Generates a dynamic range for the "Last N periods" based on the reference date. The available date ranges vary depending on the time granularity. For example, if the time granularity is day, you can set it to Last N days/months/years.

          image

        • Custom date range configuration: If the "Last N periods" setting does not meet your needs, you can set the start and end times of the range separately using relative time or absolute time.

          image

        Range preview

        The range preview updates in real time based on the selected reference date and date range, allowing you to check if the configured range meets your expectations.

        image

    • Set charts associated by start/end time only: In a dashboard, you can set charts to be associated by start/end time only, which applies the same date range to different charts.

      Three types of time range filtering are supported:

      • Limit start time

        image

      • Limit end time

        image

      • Limit time range

        image

      Note

      This option can be configured only when Interval type is set to Time interval.

Date granularity switching

When the associated field in a date query filter bar is a date field (such as year, quarter, month, week, day, or ymdhms), you can switch the date granularity to view data from different time perspectives. This feature lets you use a single control instead of multiple dashboards or tabs for different granularities.image

You can configure the date granularity switching to control only the date control or synchronously control the chart. The differences are as follows:

Configuration method

Description

Example

Date granularity switching controls only the date control

Switching the date granularity in the filter bar only affects the filter options and does not change the chart's display granularity.

This method is suitable for scenarios where you only need to change the time filter options without altering the chart's time dimension. For configuration details, see Date granularity switching controls only the date control.

The chart's current display granularity is year. In the filter bar, you select the query date granularity as month and set the month range to January-September 2023. After clicking query, the chart's display granularity remains year, showing only the total data for the period from January to September 2023 at the yearly level. The effect is shown in the figure.111

Date granularity switching synchronously controls the chart

If you configure a date dimension group in the chart's field panel, the chart's display granularity automatically follows the date granularity you select in the filter bar.

This method is suitable for scenarios where you need to flexibly switch the chart's time dimension using the filter bar to view detailed data at different time granularities. For configuration details, see Date granularity switching synchronously controls the chart.

The chart's current display granularity is year. In the filter bar, you select the query date granularity as month and set the month range to January-November 2023. After clicking query, the chart's display granularity switches to month, showing the monthly details for January to November 2023. The effect is shown in the figure.111

Control-only granularity switching

The date granularity value in the filter bar will only affect the filter options of the date control. You can configure it as follows.

  1. In the Query Condition Settings panel, set the query conditions as shown in the following figure.

    In this example, the date field is order_date (ymdhms).image

    This section describes the parameters in the Basic configuration area:

    • Time granularity: Once you select an associated field, a default value is automatically populated in the Time granularity field. The default values differ for different time granularity fields. For more information, see Time granularity.

      You can select or remove different time granularities from the drop-down list based on your needs.

    • Granularity setting: After setting the granularity, you can quickly view data from different time perspectives on a single dashboard page.

      Note

      You only need to configure the granularity setting when two or more values are selected for Time granularity.

      image

    • Set default filter value: Sets a default value for the filter bar.

      After configuring the Granularity setting, you can also set different default values for each time granularity, making it convenient to quickly query data when switching between them.

      2.gif

  2. After completing the configuration, switch the granularity in the query conditions, select a date, and click Query.

    image

    You can also switch the sub-granularity to quickly query data.

    3.gif

Note

If you configure a fiscal year for the dataset, the Fiscal year starts on setting in the filter bar follows the field configuration in the dataset and cannot be modified. For more information about fiscal year configuration, see Create a dataset.

Synchronized chart granularity switching

If a date dimension group is configured in the chart's Fields panel, you can set the current filter bar to also control the time dimension displayed in the chart when switching the time granularity. The procedure is as follows.

  1. Configure a date dimension group for the chart whose time granularity needs to be controlled.

    1. In the Data panel of the chart, click the image icon, and select New Dimension Group from the drop-down list.image

    2. In the New Dimension Group Field dialog box, configure the date fields as needed, and then click OK.image

    3. Drag the created date dimension group field into the chart's Fields panel and click Update.image

  2. Add a filter bar and set the query conditions in the Query Condition Settings panel.

    image

    Configuration

    Description

    Section ①

    Filter bar name

    Enter a custom name for the filter bar. You can name it based on its function, for example: Date filter.

    Section ②

    Chart and associated fields

    Select the charts whose date granularity needs to be controlled by the filter bar, and the date fields to be associated.

    Note
    • Charts that are not selected here will not be affected by the filter bar's time granularity switching. For example, the unselected details table in the figure.

    • Even if you select a chart, its time granularity will not be affected if it does not have a dimension group.

    Section ③

    Basic configuration

    You must select the Synchronize chart dimension with time granularity switching option to ensure that the date granularity value in the filter bar is synchronized to the associated charts. Other parameter configurations are the same as in Date granularity switching controls only the date control.

    Note
    • Ensure that you have configured the corresponding date dimension group fields for the charts you want to control.

    • It is recommended that the time granularities in the control correspond one-to-one with the time granularities in the chart's dimension group.

  3. After completing the configuration, select a time granularity in the filter bar, set a date range, and click Query. The time granularity displayed in the associated charts will be synchronized.111

    Note

    If you configure a fiscal year for the dataset, the Fiscal year starts on setting in the filter bar follows the field configuration in the dataset and cannot be modified. For more information about fiscal year configuration, see Create a dataset.