Docs Menu

Bin, Sort, and Limit Your Data

On this page

  • Bin Data
  • Sort Data
  • Limit Data

You can bin, sort, and limit data in your charts to highlight key aspects in your data.

MongoDB Charts supports binning date, numeric, and string fields in your data. Binning breaks continuous data into discrete groups called bins, with each bin containing a contiguous subset of the original values. For example, you might group users into bins by the decade they were born, or group timestamped calendar events by the month of their start date.

Example
Continuous vs Discrete Data

Continuous data can occupy any value over a continuous range. Some examples of continuous data include height, temperature, or the time a person was born.

Alternatively, discrete data is data which can only take certain values, categorized into a classification. Examples of discrete data include eye color and the number of students in a class.

Use the Sort By dropdown in the Chart Builder to sort chart data by either:

If you sort a multi-series chart generically by Value without sorting by a specific series, MongoDB Charts sorts your data based on the sum of all values in your series.

To toggle between ascending or descending sort order, click the a-z button to the right of the Sort By dropdown.

By default, Charts sorts data based on Value in descending order.

If you create a multi-series chart using a different field per series, you can sort the chart by a specific series field.

Example

The following charts use the Sample Data: Movies data source to compare the mean number of fresh and rotten Rotten Tomato ratings for movies in each genre.

This chart is sorted by the mean fresh value in descending order:

Chart sorted by fresh rating in descending order

This chart is sorted by the mean rotten value in ascending order:

Chart sorted by rotten rating in ascending order

You can apply a limit to the Category encoding channel to only include a specified number of categories in your visualization. The categories included are the first matching categories based on the sort order specified. Limiting data can be useful when visualizing data with so many categories it becomes difficult to create a meaningful chart.

When you limit your data, you may additionally enable Show "All Others" to create a new category called "All others" that combines the values of categories omitted by your limit.

Example

The following chart shows the average IMDb rating of movies from a particular country:

Movie ratings by country

The dataset contains movies from many different countries, but it would be most interesting to see which countries produce the highest-rated movies. We can accomplish this by applying a limit to only show countries with the 10 highest average ratings for movies.

Switch the Limit Results toggle to On and leave the Show input at the default value of 10.

Check Show "All Others" to create an 11th column representing the average rating of movies from countries that aren't in the top 10.

The chart is now much easier to understand, and we have a clear view of the countries with the highest-rated movies:

Movie ratings by country limited
Give Feedback
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.