Skip to main content
{% table data="demo_daily_orders" %}
    {% dimension value="category" /%}
    {% measure value="sum(total_sales)" fmt="usd1m" /%}
    {% measure value="sum(quantity)" fmt="num0" /%}
{% /table %}

Examples

Table with Measures

{% table data="demo_daily_orders" %}
    {% dimension value="category" /%}
    {% measure value="sum(total_sales)" fmt="usd1m" /%}
    {% measure value="sum(quantity)" fmt="num0" /%}
{% /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 %}

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 %}

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: Color with Conditional Colors

{% table data="demo_daily_orders" %}
    {% dimension value="category" /%}
    {% measure
        value="sum(total_sales)"
        fmt="usd1m"
        viz="color"
        color_options={
            conditional_colors="case when sum(total_sales) > 10000 then '#22c55e' when sum(total_sales) > 5000 then '#f59e0b' else '#ef4444' end"
        }
    /%}
{% /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" /%}
    {% measure
        value="sum(total_sales)"
        fmt="usd1m"
        viz="sparkline"
        sparkline_options={
            x="date"
            type="area"
        }
    /%}
{% /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 %}

Attributes

value
string
required
fmt
string
Format for values. Can be a built-in format or a custom Excel-style format code. See Value Formatting for available formats.
fmt_column
string
Column of format codes used to format values. The format code is pulled from this column for each row in the table.
viz
string
Visualization to show for this measure, including sparklines, bars, colors, and deltas.Allowed values:
  • bar
  • color
  • delta
  • sparkline
delta_options
options group
Delta visualization configuration. When present, enables delta visualization.Example:
delta_options={
  down_is_good = true
  show_symbol = true
  symbol_position = "left"
  neutral_range = []
}
Attributes:
  • down_is_good: boolean - Whether a downward trend is considered positive
  • show_symbol: boolean - Whether to show the delta symbol
  • symbol_position: string - Position of the delta symbol relative to the value
    • Allowed values:
      • left
      • right
  • neutral_range: array - Range [min, max] for neutral values. Use null for infinity (e.g., [null, 0] means anything ≤ 0 is neutral)
sparkline_options
options group
Sparkline visualization configuration. When present, enables sparkline visualization.Example:
sparkline_options={
  type = "line"
  x = "string"
  color = "string"
  fit_to_data = true
  date_grain = "year"
  date_range = { ... }
}
Attributes:
  • type: string
    • Allowed values:
      • line
      • area
      • bar
  • x: string - X-axis column (time/category column for sparkline) - required when viz type is sparkline
  • color: string - Color for the sparkline
  • fit_to_data: boolean - Whether to scale the y-axis to the data range
  • date_grain: string - Date granularity for sparkline time series
    • Allowed values:
      • year
      • quarter
      • month
      • week
      • day
      • hour
      • minute
      • second
  • date_range: options group - Date range configuration object with period, end, and date properties
bar_options
options group
Bar visualization configuration. When present, enables bar visualization.Attributes:
  • bar_color: string - Custom color for positive values. If not specified, uses default blue.
  • bar_color_negative: string - Custom color for negative values. If not specified, uses bar_color if set, otherwise default red.
  • hide_labels: boolean - When true, hides the text values and shows only the bar visualization.
  • fit_to_data: boolean - When true, scales bars to the data range instead of including zero. This makes bars use the full available width when all values are far from zero.
color_options
options group
Color scale visualization configuration. When present, enables color visualization.Example:
color_options={
  color_scale = []
  conditional_colors = "string"
  scale_column = "string"
  scale_mode = "individual"
}
Attributes:
  • color_scale: array - Custom color scale for type=“color”. Must be an array of colors (e.g., [“#ff0000”, “#00ff00”, “#0000ff”]).
  • conditional_colors: string - SQL expression that returns color values for each row. When specified, bypasses color_scale and uses explicit colors (e.g., “case when sum(sales) > 1000 then ‘#22c55e’ else ‘#ef4444’ end”).
  • scale_column: string - Column or SQL expression to use for color scale calculations when type=“color”. Supports: simple columns (e.g., “sc”), aggregated columns (e.g., “sum(sc)”), or expressions (e.g., “case when sales > 100 then 1 else 0 end”). If not specified, the measure column itself is used for scaling.
  • scale_mode: string - How to calculate min/max for color and bar visualizations. “individual” calculates range per column (default), “shared” calculates range across all related columns.
    • Allowed values:
      • individual
      • shared
viz_include_subtotals
boolean
default:"false"
Whether to apply visualizations (like color and bar charts) to subtotal rows. When false, subtotal rows will not have visualizations applied.
red_negatives
boolean
default:"false"
When true, negative values will be displayed in red (rgb(220 38 38))
title
string
align
string
Allowed values:
  • left
  • center
  • right
info
string
URL to link the info text to (can only be used with info)
Create a custom link title for the info link, placed after the info text (can only be used with info_link)
hide
boolean
default:"false"
Whether to hide this column from the table display. Hidden columns are still included in queries and can be referenced by other columns.
sort
string
Sort direction for this measure column. When specified, the table will be sorted by this column.Allowed values:
  • asc
  • desc
comparison
options group
Comparison configuration objectExample:
comparison={
  compare_vs = "prior year"
  display_type = "compared_value"
  target = "string"
  benchmark = { ... }
  hide_pct = true
  pct_fmt = "string"
  abs_fmt = "string"
}
Attributes:
  • compare_vs: string - Type of comparison to perform. Options: prior year (same period last year), prior period (previous period of same duration), target (compare against a target value), benchmark (compare against group average/aggregate)
    • Allowed values:
      • prior year
      • prior period
      • target
      • benchmark
  • display_type: string - What to display for comparison. Options: compared_value (comparison period value), abs (absolute change), pct (percentage change). Default: pct
    • Allowed values:
      • compared_value
      • abs
      • pct
  • target: string - Target value for target comparison. Can be a column name, aggregation (e.g., “sum(target_sales)”), or literal value.
  • benchmark: options group
  • hide_pct: boolean - Hide the percentage change line in comparison tooltips
  • pct_fmt: string - Format code for percentage values in comparison tooltips
  • abs_fmt: string - Format code for absolute values in comparison tooltips
hide_column_totals
boolean
Whether to hide this measure in column total/subtotal calculations. When undefined, auto-detection determines if totals should be hidden based on temporal comparison context.
hide_row_totals
boolean
Whether to hide this measure in row total/subtotal calculations. When undefined, auto-detection determines if totals should be hidden based on temporal comparison context.
date_range
options group
Use date_range to filter data for specific time periods. Accepts predefined ranges (e.g., “last 12 months”), dynamic ranges (e.g., “Last 90 days”), custom date ranges (e.g., “2020-01-01 to 2023-03-01”), or partial ranges (e.g., “from 2020-01-01”, “until 2023-03-01”)Example:
date_range={
  range = "last 7 days"
  date = "string"
}
Attributes:
  • range: string - Time period to filter. Use presets like ‘last 7 days’, dynamic patterns like ‘Last 90 days’, custom ranges like ‘2020-01-01 to 2023-03-01’, or partial ranges like ‘from 2020-01-01’.
    • Allowed values:
      • last 7 days
      • last 30 days
      • last 3 months
      • last 6 months
      • last 12 months
      • week to date
      • month to date
      • quarter to date
      • year to date
      • previous week
      • previous month
      • previous quarter
      • previous year
      • all time
  • date: string - Date column to filter on. Required when the data has multiple date columns.

Allowed Parents