Navigation
This documentation refers to the on-premises edition of MongoDB Charts. Read the Atlas service documentation to learn how to use MongoDB Charts with your Atlas project.

Data Table

Data tables represent data in a tabular view, similar to a spreadsheet. Data tables split your data into categories, with each categorization field represented in the table columns. The unique categories are represented as the table rows, and Charts displays aggregated values in the table body based on the fields selected.

Data Table Encoding Channels

Data tables use the following encoding channels:

Encoding Channel Description
Groups

The category encoding channels. Charts creates a row in the table for each unique value in this field. When multiple Groups are added to the chart, Charts creates a row for each unique combination of group fields.

Note

The Groups encoding channel supports binning for numeric and date fields.

Values The aggregation encoding channels. Charts creates a column for each field mapped into the Values channel. Charts aggregates the encoded Values fields using the selected aggregation methods and populates the grid cells with the aggregated value for the corresponding Group.
Dynamic Columns

A second Category encoding channel. When you use Dynamic Columns, Charts creates table columns based on the unique values retrieved from the field mapped into the Dynamic Columns channel. Charts uses the field mapped into the Values channel to populate the grid cells, aggregated against both the Group and Dynamic Column categories.

You cannot apply dynamic columns to a table if you have selected multiple Value encoding channels.

For an example of how to use dynamic columns, see the following example.

Note

The Dynamic Columns encoding channel supports binning for numeric and date fields.

Use Cases

Data tables have a wide variety of applications, but are most useful when comparing multiple categories of calculated values. Visual charts struggle to display multiple categories of data without losing their audience. Data tables present data with multiple categories such that you can see which value applies to which slice of data.

Data tables are also useful for showing precise data values, rather than comparing approximate values. Comparing approximate values is best done with a visual representation, instead of text.

You can use data tables to show:

  • The total cost to rent an apartment, including rent, cleaning fees, and security deposits organized by location and total area of the unit.
  • Time spent working out and total calories burned during various exercises categorized by the type of exercise and time of day the exercised was performed.

Examples

The following data table examples visualize data from a hospitality and property service. Each document in the collection represents a unit available for rent and includes information such as the monthly unit price, neighborhood, and property type.

Basic Data Table

The following data table categorizes the rental listings by property type and location, and shows the average review rating and average weekly rent for each group:

Basic Data Table Example

The Group encoding channels of property_type and suburb create a row in the data table for each unique combination of those two fields in the data.

The Values of review_scores_rating and weekly_price each add a column to the table. For both values, we average the rating and price for each property type and suburb using aggregation and display the results in the data table.

The results are formatted using the Customization tab to display the mean weekly price as currency and round the mean review score to an appropriate number of decimal places.

Note

We have applied a filter to this chart to only display listings which have a weekly_price associated with them.

Data Table with Dynamic Columns

The following data table displays nearly the same data as the previous basic data table example. In this example, instead of making property_type and suburb Groups, property_type field is now a Dynamic Column:

Basic Data Table Example

Now, rather than having two category columns in the table, the property_types become column titles. We are still aggregating the mean of the weekly_price based on each combination of property_type and suburb.

The results are formatted using the Customization tab to display the mean weekly price as currency.

Note

Blank table cells indicate that there are no documents that match the corresponding intersection of property_type and suburb.