Skip to main content

sortByColumnNumbersReverse

Sorts a table region by sorting a single column's values in descending order.

To achieve the opposite effect, use sortByColumnNumbers 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 COLUMN (string)

    The column to sort by. Give the column name as a string.

    Note: The column must contain numbers only.

Examples

Assume a "Describe the Table" project with this data:

ID

Branch

Sales

Target

Row 1

1001

New York

478,745.37

500,000

Row 2

1002

Boston

329,493.49

300,000

Row 3

1003

Los Angeles

467,359.45

450,000

Row 4

1004

Chicago

463,603.17

400,000

Note

The first table column — ID in table above — contains the row names.

To sort the table by Sales in descending order:

[[sortByColumnNumbersReverse(WholeTable,'Sales')]]

The result is this sorted table region:

 

Branch

Sales

Target

1001

New York

478,745.37

500,000

1003

Los Angeles

467,359.45

450,000

1004

Chicago

463,603.17

400,000

1002

Boston

329,493.49

300,000

You can then interrogate the sorted table with functions such as columnsInRegion and top.

[[

sortedByHighestSales = sortByColumnNumbersReverse(WholeTable,'Sales')

bestBranch = top(columnsInRegion(sortedByHighestSales,Branch),1)

bestSales = top(columnsInRegion(sortedByHighestSales,Sales),1)

bestSalesAbrv = abbreviateNumber(currencyFormat(bestSales))

"The branch with the best sales is [[bestBranch]], with a total of [[bestSalesAbrv]]."

]]

The printed output is:

The branch with the best sales is New York, with a total of $478.7K.

Note

In a "Describe Row in Context" project, the column variables are BranchColumn and SalesColumn.