Skip to content

Column Total ​

Add a total column using ALL in the COLS clause.

Interactive Example ​

Try It
TABLE
  ROWS occupation * gender
  COLS (education | ALL) * income.sum
;
Dataset:samplesoccupation, education, gender, income
Try Variations

Query Breakdown ​

  • ROWS occupation * gender - Nests gender within occupation for row headers
  • (education | ALL) - Shows each education level plus a total column
  • * income.sum - Applies the sum aggregation across all columns

The | operator concatenates the dimension with ALL, creating columns for each education value followed by a grand total column.

Powered by Malloy and DuckDB