Column Sorting

For each column in your table, you need to decide which column should control the sort order. By default, each column is ordered by itself, meaning that, if it's a text column, its values are sorted in alphabetical order. However, if the default sorting is not appropriate (for example, if the column contains month names which should be ordered chronologically and not alphabetically) you need to select a different sort order column that assures the chronological sort order.

Sorting applied from the Columns panel is executed at runtime.

Tip: Alternatively, Sorting can be applied in the Data Flow. Data Flow sorting is stored in the database schema.

Sorting Columns

Each column's sorting is controlled using the Sort column. By default, each column is sorted by itself. You can change the sorting for a given column from the Sort drop-down. The drop-down includes all columns in the current table; each column may be sorted by any other column from the same table.

Sorting Effect

Sort by Itself

This is the default configuration, where the same value is present in the column and the Sort column. In this case, only the column type affects the sorting behavior:

  • For text-based fields, the column will be sorted in alphabetical order.
  • For numeric fields, the column will be sorted in ascending numeric order.
  • For dates, the column will be sorted in chronological order.
  • For Booleans, the column will be sorted in ascending order with false values first.

As an example, the PromotionKey is an integer (as indicated by the # icon) and is sorted by itself, so its values will be sorted in ascending numeric order.

Sort by a Different Column

There are many scenarios where it's preferable to sort by a different column. For example, the expected order of month names is typically not alphabetical but chronological (January, February, ... and not April, August, ...). In this case, you need to select a sort column that provides the chronological sort order, such as a month number indicating that January is month 1, February is month 2, and so on (see the Time Intelligence Examples below).

Other examples may sort details in ways that are relevant to your business domain. For example, you might sort customers by purchase to produce a list that ranks customers from those with the most purchases to those with the fewest.

Time Intelligence Examples

Certain time intelligence columns are not sorted by themselves. Columns like Full Quarter, Full Month Name, and Full Week are sorted by numeric columns that contain the start dates for the period and Columns like Month Name and Weekday Name are sorted by number columns:

Note: In the preceding example, the Sort columns are all hidden columns that have been defined for this purpose.

One-to-one Mappings

You must ensure a one‑to‑one mapping between the values in the Column and its Sort Column to avoid unexpected or unpredictable behavior. This is particularly important when you will go on to perform calculations on your data. Put simply, if your Columns map to multiple Sort Columns or if your Sort Columns map to multiple Columns, then Pyramid will not know how to apply the order between the duplicate entries.