sortByRowNumbersReverse
Sorts a table region by sorting a single row's values in descending order.
To achieve the opposite effect, use sortByRowNumbers instead.
Note
Available in "Describe the Table" and "Describe Row in Context" projects only.
Parameters
INPUT TABLE (table region)
The table region to sort.
SORTING ROW (string)
The row to sort by. Give the row name as a string.
Examples
Assume a "Describe the Table" project with this data:
ID | Branch | Sales | Target | Profit | |
---|---|---|---|---|---|
Row 1 | 1001 | Pittsburgh | 478,745.37 | 500,000 | 8,756.34 |
Row 2 | 1002 | Boston | 329,493.49 | 300,000 | 10,451.41 |
Row 3 | 1003 | Los Angeles | 467,359.45 | 450,000 | 12,059.78 |
Row 4 | 1004 | Chicago | 463,603.17 | 400,000 | 9,452.35 |
Note
The first table column — ID in table above — contains the row names.
To get a table region comprising the Sales, Target, and Profit columns for Rows 1001 and 1002 only:
[[rowsInRegion(columns(Sales, Target, Profit), '1001', '1002')]]
The result is this table region:
Sales | Target | Profit | |
---|---|---|---|
1001 | 478,745.37 | 500,000 | 8,756.34 |
1002 | 329,493.49 | 300,000 | 10,451.41 |
To sort this region in descending order, using the values in Row 1001:
[[ inputRegion = rowsInRegion(columns(Sales, Target, Profit), '1001', '1002') sortByRowNumbersReverse(inputRegion, '1001') ]]
The result is this sorted table region:
Target | Sales | Profit | |
---|---|---|---|
1001 | 500,000 | 478,745.37 | 8,756.34 |
1002 | 300,000 | 329,493.49 | 10,451.41 |
Note
The column order has changed from Sales–Target–Profit to Target–Sales–Profit.
To sort the region in descending order, using the values in Row 1002:
[[ inputRegion = rowsInRegion(columns(Sales, Target, Profit), '1001', '1002') sortByRowNumbersReverse(inputRegion, '1002') ]]
The sort has no effect because the column order remains Sales–Target–Profit.
Sales | Target | Profit | |
---|---|---|---|
1001 | 478,745.37 | 500,000 | 8,756.34 |
1002 | 329,493.49 | 300,000 | 10,451.41 |
Note
In a "Describe Row in Context" project, the column variables are SalesColumn
, TargetColumn
, and ProfitColumn
.