Filter Dashboard Data by Date

SurveyJS Dashboard allows you to filter dashboard data by date using a dedicated date panel. This panel includes the following UI elements:

  • Date editors for selecting the start and end dates of a custom range
  • A drop-down list with predefined date periods ("Last 7 days", "Last month", "This year to date", etc.)
  • A checkbox that includes or excludes the current day for relative periods (for example, "This year to date")
  • A counter that displays the number of responses matching the applied filter
Date range filtering in SurveyJS Dashboard

This topic explains how to enable date filtering, customize the list of predefined date periods, handle date range changes, and apply a fixed (non-editable) date filter.

Enable Date Filtering

Date filtering requires a timestamp field in your response data. Assign the name of this field to the Dashboard's dateFieldName option. When this option is specified, the date panel is displayed automatically.

import { Dashboard } from "survey-analytics";

const dashboardOptions = {
  questions: [ /* ... */ ],
  data: [
    {
      // ...
      timestamp: "2026-02-22T13:40:34.954Z"
    },
    {
      // ...
      timestamp: "2026-02-23T09:23:41.512Z"
    },
    // ...
  ],
  dateFieldName: "timestamp"
};
const dashboard = new Dashboard(dashboardOptions);

View Demo

Configure Predefined Date Periods

Predefined date periods allow users to select a date range without manually specifying start and end dates. SurveyJS Dashboard supports the following period identifiers:

  • "last7days"
  • "last14days"
  • "last28days"
  • "last30days"
  • "lastWeekSun"
  • "lastWeekMon"
  • "lastMonth"
  • "lastQuarter"
  • "lastYear"
  • "ytd"
  • "mtd"
  • "wtdSun"
  • "wtdMon"
  • "qtd"

To restrict the list of available periods, specify the allowed identifiers in the availableDatePeriods array.

To define an initial period or retrieve the currently selected one, use the datePeriod property. The example below sets "Last 30 days" as the initial period:

import { Dashboard } from "survey-analytics";

const dashboardOptions = {
  questions: [ /* ... */ ],
  data: [ /* ... */ ],
  dateFieldName: "timestamp",
  datePeriod: "last30days"
};
const dashboard = new Dashboard(dashboardOptions);

View Demo

Handle Date Range Changes

To react to changes in the selected date range, use the onDateRangeChanged event. This event is raised when users select a predefined period or define a custom date range.

The event handler receives an options object. The options.dateRange property contains an array in the format [startDate, endDate] and is always defined. The options.datePeriod property contains the identifier of the selected predefined period. If users specify a custom date range, options.datePeriod is undefined.

import { Dashboard } from "survey-analytics";

const dashboardOptions = {
  // ...
};
const dashboard = new Dashboard(dashboardOptions);
dashboard.onDateRangeChanged.add((_, options) => {
  const dateRange = options.dateRange; // [ startDate, endDate ]
  const datePeriod = options.datePeriod; // undefined for custom ranges
  // ...
  // Custom logic here
  // ...
});

Apply a Fixed Date Filter

You can apply a predefined period or custom date range and prevent users from modifying it. To do this, specify either the datePeriod or dateRange option and set the showDatePanel option to false:

import { Dashboard } from "survey-analytics";

const dashboardOptions = {
  questions: [ /* ... */ ],
  data: [ /* ... */ ],
  dateFieldName: "timestamp",

  // Option 1: Predefined period
  datePeriod: "last7days",

  // Option 2: Custom range
  // dateRange: ["2026-02-01", "2026-02-10"],

  showDatePanel: false
};
const dashboard = new Dashboard(dashboardOptions);

This configuration applies the specified date filter and hides the date panel, making the filter impossible to edit for dashboard users.

Other Interactive UI Features

Send feedback to the SurveyJS team

Need help? Visit our support page

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.