Sort Rows
You can sort the ordering of rows in your dataset based on the values in one or more columns.
Sort Order
The order of rows is determined by how the application orders for a sort column's data type.For more information, see Sort Order.
Example Dataset
rowId | lastName | firstName | startDate |
---|---|---|---|
3 | Jones | Tim | 2022-05-01 |
1 | Jones | Cary | 2022-03-15 |
2 | Abbott | Michael | 2022-02-07 |
Sort by a Single Column
To sort rows by the values in a single column, click the column menu and then select one of the following options:
Sort A → Z: Sort the rows in the dataset in ascending order, as determined by the data type of the column.
Sort Z → A: Sort the rows in descending order, as determined by the data type of the column.
Transformation:
For the example dataset above, suppose you want to sort the rows based on the rowId value in ascending order. From the rowId column menu, you could select Sort A → Z, which yields the following step in your recipe.
Transformation Name | |
---|---|
Parameter: Sort by | rowId |
Results:
The resulting dataset looks like the following:
rowId | lastName | firstName | startDate |
---|---|---|---|
1 | Jones | Cary | 2022-03-15 |
2 | Abbott | Michael | 2022-02-07 |
3 | Jones | Tim | 2022-05-01 |
For more information, see Column Menus.
Reversing Sort Order
Suppose you wish to reverse the sort order of the above transformation to organize the rows in descending order based on the rowId column.
Transformation:
You can edit the recipe step and insert a dash (-
) in front of the rowId value:
Transformation Name | |
---|---|
Parameter: Sort by | -rowId |
Results:
rowId | lastName | firstName | startDate |
---|---|---|---|
3 | Jones | Tim | 2022-05-01 |
2 | Abbott | Michael | 2022-02-07 |
1 | Jones | Cary | 2022-03-15 |
Sort by Multiple Columns
You can sort by multiple columns in a single step.
Astuce
To perform multi-column sorts, search for Sort rows
in the Transform Builder and specify the columns manually.
In this example, you wish to sort the lastName column and then descending order of the firstName column.
Transformation:
This transformation looks like the following:
Transformation Name | |
---|---|
Parameter: Sort by | lastName |
Parameter: Sort by | -firstName |
Results:
rowId | lastName | firstName | startDate |
---|---|---|---|
2 | Abbott | Michael | 2022-02-07 |
3 | Jones | Tim | 2022-05-01 |
1 | Jones | Cary | 2022-03-15 |