Stat
The stat widget displays a single scalar value — one large number with an optional unit. It is the right choice whenever you want to surface a KPI at a glance.
Use it for:
- Total user count, total events, total revenue
- Averages (average session duration, average score)
- Conversion rates and percentages
- Any single-number metric
Query requirements
Section titled “Query requirements”A stat widget must receive exactly one row with one column.
To filter by a category (e.g. only one country or platform), put the filter in the WHERE clause — do not SELECT the category column.
Select
count() AS valueFilters
WHERE name = 'app_started' AND country = 'France'-- Wrong: two columns + GROUP BY → multiple rowsSELECT country, count() AS countFROM {table}WHERE country = 'France'GROUP BY countryPercentage stat
Section titled “Percentage stat”To display a ratio as a percentage (e.g. “what % of users who started level 1 completed level 5?”), return two columns: a value column (the numerator) and a total column (the denominator). The frontend computes value / total and renders it as a percentage.
Select
uniqExactIf(identity, name = 'level_5_completed') AS value,uniqExactIf(identity, name = 'level_1_started') AS totalFilters
WHERE name IN ('level_1_started', 'level_5_completed')Set Display format to percent and Unit to %.
Column name matching rules:
- The
valuecolumn must match one of:value,count,amount,sum,qty,val - The
totalcolumn must match one of:total,base,all,records,denominator
Common examples
Section titled “Common examples”Total unique users (simple mode)
Select: uniqExact(identity) AS value
Filters: WHERE name = 'app_started'
Total sessions (simple mode)
Select: count() AS value
Filters: WHERE name = 'app_started'
Average session duration — requires a subquery, use full query mode
SELECT formatReadableTimeDelta(avg(duration_minutes) * 60) AS valueFROM ( SELECT toFloat64((last_event - first_event) / 60) AS duration_minutes FROM ( SELECT session_id, MIN(timestamp) AS first_event, MAX(timestamp) AS last_event, minIf(timestamp, name = 'app_started') AS app_started_ts FROM {table} GROUP BY session_id ) WHERE app_started_ts = first_event)Conversion rate: level 1 → level 5 (simple mode)
Select:
uniqExactIf(identity, name = 'level_5_completed') AS value,uniqExactIf(identity, name = 'level_1_started') AS totalFilters: WHERE name IN ('level_1_started', 'level_5_completed')
Display format: percent — Unit: %