Skip to content

Order Ascending by Value ​

Use ASC@aggregate to order all rows in ascending order by a computed value. This shows all occupations ordered by income from lowest to highest.

Interactive Example ​

Try It
TABLE
  ROWS occupation ASC@income.sum
  COLS education * income.sum
;
Dataset:samplesoccupation, education, gender, income
Try Variations

Query Breakdown ​

  • TABLE - Declares a crosstab table statement
  • ROWS occupation ASC@income.sum - All occupations ordered by income ascending
    • ASC - Ascending order (lowest values first)
    • @income.sum - Order by this aggregate value, not alphabetically
    • No bracket limit - shows all values
  • COLS education * income.sum - Column dimension with education breakdown
  • income.sum - Measure: sum of income for each cell

Use ASC@ for ascending (lowest first) and DESC@ for descending (highest first). Without a bracket limit like [5], all rows are shown in the specified order.

Powered by Malloy and DuckDB