Docs Menu
Docs Home
Atlas Charts

Filter Chart Results

On this page

  • Create Filters for Your Data
  • Display Strings and ObjectIds Not in the List
  • Specify a Time Zone
  • Enable or Disable a Filter
  • Expand or Collapse a Filter
  • Filter Your Data Using the Query Bar
  • Address Query Errors
  • Considerations

Filters display a subset of results that match a given criteria. Atlas Charts provides two ways to filter the data for a single chart. You can either use:

  • The Filter Tab's numeric, string, date, or boolean fields to handle most of your data filtering needs.

  • The Query Bar to filter your data using more complex queries, such as logical operator queries, or process raw data by using the aggregation pipeline.

To learn how to filter results across multiple charts on your dashboard, see Filter Dashboards by Field Values.

The chart builder contains a filter tab where you can drag and drop fields to specify filters for your data. To filter data using the filter tab:

  1. Click the center tab in the chart builder:

    Image showing how to access filter tab

  2. Drag a field from the Fields on the left to the Chart Filters section of the tab.

The data type of the selected field determines the available filtering options. You can filter fields with the following data types:


You cannot use the same field in multiple filters.

You can toggle whether a filter in the Filter tab is enabled or disabled. Disabled filters do not affect the documents which appear in the chart. Disabled filters are grayed out and cannot be edited until they are enabled.

To toggle whether a filter is enabled, hover over a filter and set the toggle that appears at the top of the filter to the desired setting.

Image showing filter toggle
click to enlarge

You can expand or collapse chart filter cards by clicking Show or Hide on that card.

Disabled filters are automatically collapsed.

Enabled, collapsed filters are still applied to your charts.

The Query bar above the chart display supports more complex queries than the filter panel. Additionally, you can use the query bar to create aggregation pipelines to process your data before it is rendered.

To filter data using the Query bar:

  1. In the Query bar, input a filter document. Use the same syntax used in the query portion of the db.collection.find() method. Your filter document must be in curly brackets.

  2. Click Apply.

The following tabs show how to construct queries with the following operators:

  • $or logical operator to match documents where at least one clause is true

  • $exists query operator to match documents with an element that exists

  • $regex query operator to match documents with a regular expression

  • Date field to match documents with specific dates

If your query is invalid, Charts displays the icon in the Query bar.

Click the Query bar if it is not already displayed to view error details. Charts displays error details for:

  • Client-side errors, such as malformed JSON, and

  • Server-side errors, such as invalid MQL.

Example Filter Error
click to enlarge

Review the error details, then adjust your query accordingly.

  • Filters on large collections may encounter performance issues if the collection is not appropriately indexed.

  • The date functions used in the Atlas Charts query bar are consistent and compatible with the date functions used in the mongo shell. As a result, you can use:

    • new Date(),

    • ISODate(), or

    • new ISODate().

    The Date() function (as opposed to the new Date() constructor) returns the current date as a string, so it cannot be used for querying dates in Charts.

← Save and Reuse Queries