Writing queries
Every widget is powered by a query against one data source. The query step in the widget editor is where you write it, run it, and inspect a preview.
SQL databases and warehouses
For PostgreSQL, MySQL, SQL Server, Oracle, Aurora, Redshift, Snowflake, and BigQuery, the query is SQL in the dialect of that engine. CustomerDashboard does not rewrite your SQL except to bind :customer_id on customer dashboards.
A few habits that keep widgets reliable:
- Return one row per thing you want to plot (one month, one category, one customer — depending on the chart).
- Give columns stable, readable names. Those names become field-mapping choices.
- Aggregate in SQL when the chart should show totals, not raw events — except histograms, which want raw numeric values.
- Keep the result small enough to chart. The editor preview shows the first 50 rows; the published widget uses the full result within the platform limit.
Example for a line chart:
SELECT
date_trunc('month', created_at) AS month,
SUM(amount) AS revenue,
COUNT(*) AS orders
FROM orders
WHERE account_id = :customer_id
GROUP BY 1
ORDER BY 1
Schema browser
The left side of the query step lists tables (or sheets) and their columns. On a database source, expand a table to see types. On Google Sheets, click a sheet name to fill the range field.
Google Sheets ranges
For a Google Sheets data source the “query” is a sheet name or A1 range, not SQL.
Examples:
Sheet1— the whole sheetSheet1!A2:F100— a block, useful when the first rows are titles you want to skip
The first row of the range is treated as column headers. Those headers become the fields you map on the visualization step.
Per-customer filtering is not available for Sheets. All customers see the same range. See multi-customer dashboards.
Preview as a customer
On a customer dashboard, pick which customer the test run should use — a real customer or the test customer ID. The published dashboard ignores that picker and always binds the signed-in customer’s ID.
Auto-refresh
Each widget can refetch on an interval (10 seconds through 1 hour, or never). Use a short interval for operational boards and a longer one for heavy warehouse queries.
The published viewer uses the same interval. Internal users watching a TV dashboard usually want auto-refresh on.