Skip to content

Deep Hierarchy ​

Multiple nesting levels with totals at each level using the (dimension | ALL) pattern.

Interactive Example ​

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

Query Breakdown ​

  • occupation[-5@income.sum] | ALL - Top 5 occupations by income, plus a grand total row
  • (gender | ALL) - Gender breakdown with subtotal for each occupation
  • (education | ALL) - Education columns with total column
  • income.sum - Sum of income as the measure

The (dimension | ALL) pattern at each level creates a hierarchical structure with totals. The occupation level shows the top 5 plus a grand total. Within each occupation, gender shows Male, Female, plus a subtotal. Columns show each education level plus an overall total.

Powered by Malloy and DuckDB