Skip to main content
Basic Usage
{% delta 
	data="demo_daily_orders" 
	value="sum(total_sales)"
	comparison={
		compare_vs="target"
		target="120000000"
	}
/%}

Examples

Basic Usage

Basic Usage
{% delta 
	data="demo_daily_orders" 
	value="sum(total_sales)"
	comparison={
		compare_vs="target"
		target="120000000"
	}
/%}

Attributes

data
string
required
Table or view to query
value
string
required
SQL expression to insert into the SELECT part of the query (e.g., “COUNT(*)”, “SUM(sales)”)
fmt
string
Format code for the value (e.g., “num”, “usd”, “pct”). See formatValue documentation for available formats. See Value Formatting for available formats.
text
string
Text appearing after the delta (e.g., vs. prev month)
chip
boolean
default:"false"
Whether to display as a chip
comparison
options group
Comparison configuration objectExample:
comparison={
  compare_vs = "prior year"
  display_type = "compared_value"
  target = "string"
  benchmark = {
    agg = "avg"
    subject = "store_name"
    within = ["region"]
  }
  hide_pct = true
  pct_fmt = "string"
  abs_fmt = "string"
  down_is_good = true
}
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
    • Options:
      • agg: string - Aggregation function to apply across benchmark group. Options: avg (average), median, min, max, sum, count, count_distinct
        • Allowed values:
          • avg
          • median
          • min
          • max
          • sum
          • count
          • count_distinct
      • subject: string - Column or expression that defines individual entities in the benchmark (e.g., “store_name”, “customer_id”). Required for single-value components.
      • value: string - Optional column or expression to use for benchmark calculation. If not specified, uses the main value column. Useful if you have a pre-aggregated benchmark table for RLS reasons.
      • within: array of strings - Dimension columns to group the benchmark by (e.g., [“region”]). Leave empty for dataset-wide benchmark.
      • where: string - SQL WHERE clause to filter which entities are included in the benchmark
      • exclude_self: boolean - Exclude the current row from its own benchmark calculation (table context only). Default: false
  • 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
  • down_is_good: boolean - Whether a downward trend is considered positive
show_value
boolean
default:"true"
Whether to show the value
show_symbol
boolean
default:"true"
Whether to show the delta symbol
symbol_position
string
default:"right"
Position of the delta symbol relative to the valueAllowed values:
  • left
  • right
neutral_range
array
default:"[0,0]"
Range [min, max] for neutral values. Use null for infinity (e.g., [null, 0] means anything ≤ 0 is neutral)
filters
array
IDs of filters to apply to the query
refresh_interval
number
Time in seconds between automatic data refreshes (minimum 60). Overrides the page-level auto-refresh setting for this component.
where
string
Custom SQL WHERE condition to apply to the query. For date filters, use date_range instead.
having
string
Custom SQL HAVING condition to apply to the query after GROUP BY
limit
number
Maximum number of rows to return from the query. Note: When used with tables, limit will disable subtotals to prevent incomplete subtotal rows.
order
string
Column name(s) with optional direction (e.g. “column_name”, “column_name desc”)
qualify
string
Custom SQL QUALIFY condition to filter windowed results
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.
width
number
Set the width of this component (in percent) relative to the page width