Example
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% pivot
value="date"
date_grain="year"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
/%}
{% /table %}
Date Range Filtering
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
date_range={
range="last 12 months"
date="date"
}
fmt="usd1m"
/%}
{% measure
value="sum(total_sales)"
date_range={
range="last 6 months"
date="date"
}
fmt="usd1m"
/%}
{% /table %}
Pivoting
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% pivot
value="date"
date_grain="year"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
/%}
{% /table %}
Prior Year Comparison
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
date_range={
range="last 12 months"
date="date"
}
comparison={
compare_vs="prior year"
}
/%}
{% /table %}
Calculated Measures
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales) / sum(transactions) as avg_price"
fmt="usd2"
/%}
{% /table %}
Custom Grouping
{% table
data="demo_daily_orders"
%}
{% dimension
value="case when category in ('Home','Clothing') then 'Home & Clothing' else 'Other' end as group"
/%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
/%}
{% measure
value="sum(total_sales) / sum(transactions) as avg_price"
fmt="usd2"
/%}
{% /table %}
Viz: Color Scale
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="color"
/%}
{% /table %}
Viz: Color Scale with Custom Colors
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="color"
color_options={
color_scale=["#c0392b","#f4f4f4","#27ae60"]
}
/%}
{% /table %}
Viz: Bar
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="bar"
/%}
{% /table %}
Viz: Bar with Custom Colors
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="bar"
bar_options={
bar_color="#2c7d00"
}
/%}
{% measure
value="sum(transactions)"
viz="bar"
bar_options={
bar_color="#339e9c"
}
/%}
{% /table %}
Viz: Delta
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
date_range={
range="last 12 months"
date="date"
}
comparison={
compare_vs="prior year"
}
viz="delta"
/%}
{% /table %}
Viz: Sparkline
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% pivot
value="date"
date_grain="year"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="sparkline"
sparkline_options={
x="date"
type="area"
}
/%}
{% /table %}
Links
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
link="concat('https://www.google.com/search?q=',category)"
link_new_tab=true
/%}
{% measure
value="sum(total_sales)"
/%}
{% /table %}
Column Info
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
info="Includes all product sales"
/%}
{% /table %}
Sorting
{% table
data="demo_daily_orders"
%}
{% dimension
value="category"
/%}
{% measure
value="sum(total_sales)"
fmt="usd1m"
viz="color"
sort="asc"
/%}
{% /table %}
Date Grains: Day of Week
{% table
data="demo_daily_orders"
%}
{% dimension
value="date"
date_grain="day of week"
/%}
{% measure
value="sum(total_sales)"
/%}
{% /table %}
Attributes
Use date_range to filter data for specific time periods like last 12 months, year-to-date, etcExample:date_range={
range = value
date = "string"
}
Attributes:
Custom SQL WHERE condition to apply to the query. For date filters, use date_range instead.
Custom SQL HAVING condition to apply to the query after GROUP BY
Maximum number of rows to return from the query
Column name(s) with optional direction (e.g. “column_name”, “column_name desc”)
Custom SQL QUALIFY condition to filter windowed results
Title to display above the table
Subtitle to display below the title
Info text to display in a tooltip next to the title. Can only be used with the title prop.
Array of dimension column names or SQL expressions. Each item must be a string (e.g., [“column_name”, “count(category) as count”])
Array of pivot column names or SQL expressions. These will be pivoted in the table output. Each item must be a string (e.g., [“category”, “region”])
Array of SQL expressions for aggregations. Each item must be a string (e.g., [“sum(transactions)”, “avg(value) as average”])
Whether to include subtotals in the table
Whether to put measures before pivots in the column hierarchy (e.g., Sales > 2021|2022 instead of 2021|2022 > Sales)
Number of rows to display per page in pagination
Whether to display a search box above the table for filtering results
Whether to apply formatting to column titles. When false, titles will be displayed as-is.
Whether to allow column titles to wrap across multiple lines. When false, titles will be on a single line.
Whether to allow table cell content to wrap across multiple lines. When false, cell content will be on a single line.
Whether to apply alternating background colors to table rows for easier reading.
Whether to display borders between table rows. When false, row borders are hidden.
Column name containing URLs to make each row clickable. When specified, clicking a row will navigate to the URL in that column.
Whether to display the link column in the table. Only applies when no explicit columns are specified and the link prop is used.
Set the width of this component (in percent) relative to the page width
Allowed Children