sortedColumnsInRegion
Selects columns from a specific table region and presents them in the selected order.
This function is similar to columnsInRegion. Both functions return a table region of selected columns, but sortedColumnsInRegion
presents the columns in the selected order, not the order in your sample data.
Note
Available in "Describe the Table" and "Describe Row in Context" projects only.
Parameters
REGION (table region)
A table region to select columns from.
COLUMN NAME (column or string)
A column you wish to select.
COLUMN NAME (column or string)
Optional. Another column you wish to select.
Notes
You can select as many columns as required.
The input to each parameter can be a column variable or column name (string).
Examples
Assume a "Describe the Table" project with this data:
ID | Branch | Manager | Sales | COGS | otherExp | Profit | |
---|---|---|---|---|---|---|---|
Row 1 | 1 | Aberdeen | Andrew Gray | 14,000 | 8,000 | 1,500 | 4,500 |
Row 2 | 2 | Edinburgh | Emma Moore | 33,000 | 19,000 | 3,500 | 10,500 |
Row 3 | 3 | Inverness | Linda Barclay | 16,000 | 8,250 | 1,500 | 6,250 |
Row 4 | 4 | Glasgow | Louise Scott | 32,500 | 17,750 | 1,700 | 13,050 |
The input to the first parameter must return a table region.
[[ filteredData = filterRows(WholeTable, Sales, gt(30000)) sortedColumnsInRegion(filteredData, Manager, Branch, Profit) ]]
The first line uses filterRows to get rows with a Sales value greater than 30,000. This ATL is assigned to a variable called filteredData
. The second line uses this variable when calling sortedColumnsInRegion
.
In this example, the selected columns are Manager, Branch, and Profit. Column variables are given.
The return value is this table region:
| Manager | Branch | Profit |
---|---|---|---|
2 | Emma Moore | Edinburgh | 10,500 |
4 | Louise Scott | Glasgow | 13,050 |
Note that the Manager column now appears before the Branch column (compare with original table). Also, note that the row names — the ID values from the original table — are also included.
To get the same output in a "Describe Row in Context" project, the ATL is:
[[ filteredData = filterRows(WholeTable, SalesColumn, gt(30000)) sortedColumnsInRegion(filteredData, ManagerColumn, BranchColumn, ProfitColumn) ]]