Skip to main content

Sort and group data in tables

Sort table data by one or more columns and group rows into collapsible categories. Add summary calculations like totals and counts to groups. Includes guidance on optimising workbook performance.

Updated over a month ago

Sorting arranges your data in a meaningful order—alphabetically, by date, or by value. Grouping takes this further by organising rows into categories and automatically calculating summaries for each category. Together, these features help you find patterns and compare values across your data, similar to how you might sort a column or use subtotals in Excel.

Some data models provided by Altruistiq already have sorting and grouping applied to make analysis easier. When you create a table from these data models, you may find the structure you need is already in place.


Sorting

Sort by a single column

The quickest way to sort a table is by a single column. This works the same way as sorting in Excel—click a column header option and choose your sort direction.

  1. Hover over the column you want to sort by and click the column menu (▼).

  2. Select Sort ascending to arrange values from A to Z, smallest to largest, or oldest to newest. Alternatively, select Sort descending to arrange values from Z to A, largest to smallest, or newest to oldest.

The table reorders immediately based on your selection. A sort indicator appears on the column header to show the active sort.

Sort by multiple columns

When you need more control—for example, sorting by region first, then by date within each region—use custom sort to define multiple sorting rules.

  1. Click the column menu (▼) on any column in your table.

  2. Next to Sort, click the settings icon to open the Sort pop-up.

  3. For Column name, select the first column you want to sort by.

  4. For Sort order, choose your preferred direction:

    • Text columns: A to Z or Z to A

    • Number columns: Smallest to largest or Largest to smallest

    • Date columns: Oldest to newest or Newest to oldest

  5. For Nulls, choose how to handle empty values:

    • Default: uses the standard Altruistiq behaviour for ordering empty values

    • First: puts empty values at the top of the sorted column

    • Last: puts empty values at the bottom of the sorted column

  6. To add another sorting level, click Add new and repeat steps 3–5.

  7. Click Save.

The table now sorts by your first column, then by subsequent columns within groups of identical values.

💡 Tip: Define your sorting rules in the order you want them applied. You cannot reorder rules after creating them—if you need a different order, remove the rules and add them again in the correct sequence.

⚠️ Performance note: Sorting is processed live when you load the page. Adding many sorting rules to large tables may increase loading times.


Grouping

Add groupings to a table

Grouping organises your data into categories based on shared values. When you group by a column, the table creates collapsible sections for each unique value in that column, with automatic summaries for each group.

This is similar to Excel's subtotal feature or the row grouping you might create manually, but it updates automatically as your data changes.

Some data models provided by Altruistiq already include groupings to help you get started. Check whether the data model you're using has pre-configured groupings before adding your own.

  1. Select the table you want to group.

  2. In the Editor panel, locate the Groupings section.

  3. Click Add grouping... and select the column you want to group by.

The table reorganises to show each unique value from your chosen column as a group header. A vertical line separates the grouping column from the rest of your data. You can expand or collapse groups using the + and icons next to each group header.

Example: If you group emissions data by Supplier, each supplier becomes a collapsible section. Click the next to a supplier name to collapse that section and see just the group summary; click + to expand and see all the individual rows.

Add calculations to groups

Once you have a grouping, you can add calculations that summarise data for each group—such as totals, averages, or counts.

  1. Select your grouped table.

  2. In the Editor panel, find your grouping under the Groupings section.

  3. Next to Calculations, click Add calculation....

  4. Select the column you want to summarise.

A new calculated column appears within the grouping, showing the summary value for each group. By default, number columns are summed and text columns are counted.

⚠️ Performance note: Calculated columns are computed live each time the page loads. Adding many calculations to a workbook may increase loading times, particularly with large datasets. Where possible, keep the number of calculations to what you genuinely need for your analysis.

Change the calculation type using the Editor panel

  1. In the Editor panel, hover over the calculated column name.

  2. Click the column menu (▼) and select Set aggregate.

  3. Choose your preferred calculation: Sum, Avg (average), Count, CountDistinct (unique values), Min, Max, or Median.

Change the calculation using the formula bar

For more control over your calculation, you can edit the formula directly:

  1. Select the calculated column in your table.

  2. Look at the formula bar at the top of the page—it displays the current formula for this column.

  3. Edit the formula to change how the calculation works. For example:

    • Change Sum([CO2e]) to Avg([CO2e]) to show an average instead of a total

    • Add conditions, such as SumIf([Category] = "Scope 1", [CO2e]) to sum only specific values

  4. Press Enter or click the checkmark (✓) to apply your changes.

See Formula basics for more on writing and editing formulas.

Example: After grouping by Supplier, you might add a calculation on CO2e to see total emissions per supplier, then add another calculation on Product ID set to CountDistinct to see how many unique products each supplier provides.

Add multiple grouping levels

You can create nested groupings to analyse data at multiple levels—for example, grouping first by region, then by supplier within each region.

  1. With an existing grouping in place, click Add grouping... again in the Editor panel.

  2. Select a second column to group by.

The table now shows a hierarchy: your first grouping column at the top level, with your second grouping nested inside it. Each level can have its own calculations.

Expand and collapse groups

Groupings are collapsible, letting you focus on summary data or drill into detail as needed.

  • Click next to a group header to collapse that group and show only the summary row.

  • Click + to expand the group and reveal all its rows.

  • Click at the top of the grouping column (next to the column name) to collapse all groups at once.

  • Click + at the top to expand all groups.

When groups are collapsed, you see only the summary values from your calculations, making it easier to compare across groups.

Show totals and subtotals

By default, grouped tables don't display grand totals or subtotals. Follow these steps to turn them on.

To show a grand total:

  1. In your grouped table, click the column menu (▼) on any column within your grouping.

  2. Select the option labelled with your column name followed by totals (for example, Supplier totals).

  3. Click Show grand total.

A grand total row appears at the bottom of your table, summarising all values.

To show subtotals (when you have multiple grouping levels):

  1. Click the column menu (▼) on the first group-by column in the higher-level grouping.

  2. Select the option labelled with your column name followed by totals.

  3. Click Show subtotal.

Subtotals appear for each group at that level.

To show all totals at once:

  1. Right-click anywhere in the table to open the context menu.

  2. Select Show all totals.

This displays both grand totals and subtotals for all grouping levels. If some totals are already showing, select Hide all totals first, then select Show all totals to display the complete set.

Remove groupings

To return your table to a flat, ungrouped view:

  1. In the Editor panel, find the grouping you want to remove.

  2. Click the more menu (⋮) next to Group by.

  3. Select Remove grouping.

The table returns to showing individual rows without grouping. Any calculations you added to the grouping are also removed.

To remove a single column from a grouping while keeping the grouping structure:

  1. Click the column menu (▼) on the column within the grouping.

  2. Select Remove from grouping.


Tips for effective sorting and grouping

  • Start with sorting for simple analysis. If you just need to find the highest or lowest values, sorting is often sufficient. Use grouping when you need to see summaries for categories.

  • Group by categorical data. Grouping works best with columns that have a limited number of distinct values—such as region, supplier, category, or year. Grouping by a column with thousands of unique values creates an unwieldy table and may slow down performance.

  • Filter first for better performance. Apply filters before adding groupings and calculations. Reducing your dataset first means less data to process, which improves loading times and keeps your workbook responsive.

  • Keep calculations focused. Only add the calculations you need for your analysis. Each calculation is processed live when the page loads, so removing unused calculations helps maintain performance.

  • Consider your audience. If you're sharing a workbook with viewers, collapsed groups provide a cleaner initial view. Viewers can expand groups to explore detail as needed.


Related articles

  • Filter data in tables and charts

  • Working with pivot tables

  • Create and manage tables

  • Formula basics

Did this answer your question?