Skip to content

Complex Crosstab ​

Full-featured table combining nesting, totals, limits, and multiple aggregates.

Interactive Example ​

Try It
TABLE
  WHERE occupation IS NOT NULL
  ROWS (sector_label | ALL) * occupation[-3@income.sum] * gender
  COLS (education | ALL) * (income.sum:currency | income.mean:decimal.2)
;
Dataset:samplesoccupation, education, gender, income
Try Variations

Query Breakdown ​

  • (sector_label | ALL) - Sector dimension with grand total row
  • occupation[-3@income.sum] - Top 3 occupations by total income within each sector
  • gender - Third level of row nesting for male/female breakdown
  • (education | ALL) - Education dimension with grand total column
  • (income.sum:currency | income.mean:decimal.2) - Two aggregates side-by-side: sum formatted as currency and mean with 2 decimal places

This query creates a professional financial table with three levels of row hierarchy, totals at both row and column levels, and multiple formatted aggregates.

Powered by Malloy and DuckDB