Configure Sort in Query

You can configure how your query will be sorted. In the Multi-level Sorting menu you can set one or multiple levels of sorting. Following the steps from How to Create a Query. Here are the steps to configure sort in a query.

  1. Go to Analytics > Dashboard Manager > Queries.

  2. Open an existing query.

  3. Click on the Series (S1) building block.

    Series building block S1 with the Gapminder source in the query editor.
    Series building block
  4. In the Series settings section:

    1. Click Add Section.

    2. Select Sort Data.
      info Defines how rows are ordered at this step of the query.

    3. In the Sort Data section:

      1. Click Add Level.

      2. Select the Column from the drop-down menu.

      3. Select the Order type:

        1. Ascending

        2. Descending

    4. Close the series setting section.

      Sort Data section in the Series settings with one sort level. The data is sorted by Population in ascending order. Below the level is the Add Level button.
      Sort Data settings
  5. Click Save.

This action will sort your data by a single column. By adding another column you can set a multi-level sorting.

Example

The following example shows table sorted by the following two levels:

  • Population (Descending)

  • Life Expectancy (Descending)

Sort Data section with two sort levels. The data is sorted by Population in descending order, then by Life Expectancy in descending order. Below the levels is the Add Level button.
Multi-level sort settings

Not Sorted Table

Shows an example of the initial, not-sorted dataset.

Output preview table with Afghanistan rows in their original order, with the years 1950 to 1959 ascending and Population increasing. Columns include Country, Fertility, Life Expectancy, Population, Region, Year, and ID_Country_Year.
Data before sorting

Multi-level Sorted Table

Shows an example of what the sorted data would look like after applying the steps.

Output preview table with the same Afghanistan rows sorted by Population in descending order, so the rows now run from 1959 to 1950. Columns include Country, Fertility, Life Expectancy, Population, Region, Year, and ID_Country_Year.
Data after multi-level sorting

Sort Data is an independent block. The data passed to later blocks is already sorted at that point.