Interactive Playground ​
Experiment with TPLm queries in your browser. All queries run locally using DuckDB WASM with a sample employment survey dataset.
Query Editor ​
Write your TPL query and click Run to see results:
TPL Query
TABLE ROWS occupation[5] * income.sum COLS education;
Dataset:
samplesoccupation, education, gender, incomeDimension Definitions ​
Expand this section to view or customize the computed dimensions. Changes apply to all queries on this page.
Dimension Definitions
Definition Order
Notice how occupation[5] returns the first 5 occupations by definition order (Managerial, Professional, Technical...) rather than alphabetically. TPL automatically detects pick expressions and sorts by declaration order.
More Examples ​
Simple Table
TABLE ROWS occupation * income.sum;
Dataset:
samplesoccupation, education, gender, incomeBasic Crosstab
TABLE ROWS occupation * income.sum COLS education;
Dataset:
samplesoccupation, education, gender, incomeAdvanced Example
TABLE ROWS occupation[-5@income.sum] * (gender | ALL) * income.(sum | mean) COLS education | ALL;
Dataset:
samplesoccupation, education, gender, incomeQuick Reference ​
Basic Structure ​
sql
TABLE [FROM source] [WHERE condition]
ROWS <row-axis>
[COLS <column-axis>];Common Patterns ​
Nesting (*) ​
sql
-- Each state contains cities
state * cityConcatenation (|) ​
sql
-- State section followed by gender section
state | genderTotals (ALL) ​
sql
-- Row with total
(state | ALL)
-- Column with total
COLS year | ALLLimits and Ordering ​
sql
-- Top 10 by value
state[-10@births.sum]
-- Bottom 5 alphabetically
state[5]Percentages (ACROSS) ​
sql
-- Row percentages (each row sums to 100%)
income.sum ACROSS COLS
-- Column percentages
income.sum ACROSS ROWS
-- Cell percentages
income.sum ACROSSMore Examples ​
Explore categorized examples in the sidebar:
- Core Concepts - Basic building blocks
- Totals - Marginals and subtotals
- Limits - Top N and ordering
- Percentages - Ratio calculations
- Advanced - Complex patterns