Table or SQL Dataset
Choose between a table dataset and a SQL dataset, and let dashboard values narrow a SQL dataset from inside its query
A dataset in a semantic domain comes from one of two places: a table or view in your database, or a SQL query you write in the domain (a SQL dataset). People building cards can't tell them apart. Both show up in the field list, join through relationships, and take filters the same way. The choice is about where the shaping of the rows happens.
Start with a table dataset
Add a table or view as a dataset when it already holds the rows you want to count: an orders table, a customers table, a view your data team maintains. Filters, relationships, calculated fields and drill all work on it, and every card reads only the columns it needs.
Most domains are mostly table datasets.
Use a SQL dataset when the rows need shaping first
Write a SQL dataset when the rows a card should start from don't exist as a table or view yet:
| You want | Use |
|---|---|
| Every row of a table, filtered by whoever views the dashboard | A table dataset and a dashboard filter |
| Only some rows, always (for example, completed orders only) | A SQL dataset with that WHERE |
| A join or rollup you'd otherwise repeat on every card | A SQL dataset |
| A value worked out per row before cards group (for example, each customer's first order date) | A SQL dataset |
| A value the viewer picks applied inside the query (before a rollup, or across two columns) | A SQL dataset with dataset inputs, below |
If your team can add a view to the database, a view added as a table dataset does the same job and keeps the SQL in the database. A SQL dataset keeps it in the domain, where you can change it without database access.
Example: completed orders for the dates a viewer picks
This walkthrough builds a SQL dataset of completed orders with a declared Date range input, then filters it from a dashboard.
1. Write the SQL dataset and declare its input
In the domain editor, add a dataset in SQL Dataset mode and write the SQL. Then click Declare on order_window, which the editor lists as Not declared (or click Add input → Limit a field → order_date and copy its references into your condition):
SELECT order_id, order_date, region, category, sales
FROM analytics.orders
WHERE status = 'completed'
AND order_date BETWEEN {{ param('order_window').start }} AND {{ param('order_window').end }}In the Inputs panel on the right:
- Type: Date range
- Who sets it: Filter, on the field
order_date - Required: On (or leave off and wrap the predicate in
{% if param('order_window').present %} ... {% endif %}if viewers should be able to clear the dates) - Default: Last 12 months (or leave blank to prompt the dashboard author to add a filter)
Click Preview Columns, then Apply and Save the domain.
2. Add the input filter to the dashboard
On the dashboard, build cards on completed_orders (tables, charts, KPIs, or Matrix tables). Open the Filter picker: Order window is listed under Completed Orders → Inputs, marked Needed by its cards while it has no value. Click it to add the date range chip to the toolbar—no manual control wiring needed.
If the input is required and has no default, cards on completed_orders show a one-click Add Order window filter button directly on the card.
3. Build cards—and optionally share the date filter across datasets
When a viewer picks January 1 to March 31, every card on completed_orders runs:
SELECT order_id, order_date, region, category, sales
FROM analytics.orders
WHERE status = 'completed'
AND order_date BETWEEN '2026-01-01' AND '2026-03-31'Need that same Order window chip to filter a separate table dataset on the same sheet (such as store_sales)? Open the filter's Cards tab and map it to store_sales.sale_date. Cards on completed_orders keep taking the range through SQL, while store_sales filters on its own date column.
Exports, PDFs, bookmarks, scheduled reports, and Briefings all carry the same resolved dates.
When a regular filter is enough
A regular dashboard filter on order_date also narrows these cards. A filter applies to the rows your SQL returns, after it runs. Use one when that gives the right answer—it needs no template syntax and supports period-over-period comparisons.
Use a dataset input when the value has to act inside the query:
-
Before a rollup or join. If the SQL totals sales per customer, an outer filter can only remove customers from the totals. An input changes which orders go into each total.
-
Across two columns. "Orders still open on a date" compares one Date Control input (
as_of_date) against both the order date and the ship date:SELECT order_id, region, sales FROM analytics.orders WHERE order_date <= {{ param('as_of_date') }} AND (ship_date IS NULL OR ship_date > {{ param('as_of_date') }})On the dashboard, Add control suggests
as_of_datefirst, ready to use: a date picker with its default (such as Previous business day) already set. Click it to add the control to the toolbar, and the dashboard's Controls panel showsUsed by Completed Orders. -
Choosing the query's shape.
{% if %}can switch a grouping or a join on an input's value. See Templating virtual-dataset SQL.
Inside a SQL dataset, read dashboard values with param(...). Filter expressions such as {{ filters | where }} don't reach a dataset's SQL on every card type, Matrix tables included.
Tips
- Make optional inputs safe when empty. Wrap optional inputs in
{% if param('name').present %} ... {% endif %}—Preview Columns checks optional inputs with no value so clearing a chip on a dashboard never breaks the query. - Values are typed. Date inputs arrive as quoted calendar dates (
'2026-01-01'), date ranges expand.startand.end, lists expand.listforIN (...), and numbers render unquoted. If your database needs an explicit cast on a date string, useCAST({{ param('as_of_date') }} AS DATE). - Period comparisons don't shift input dates. Period-over-period comparisons (
vs previous period,vs last year) are refused while a card's dataset has an activeDateorDate rangeinput, because the SQL input clips the previous period. Compare against a fixed target or narrow dates with a regular date filter instead. - Inputs narrow data; they aren't security. Viewers can change an unlocked filter or control. To decide who sees which rows, use access control.
- Host apps can pass values. When embedding a dashboard, you can pass filter and control values from your application. See Embedding Controls.
- Not on Google Sheets or uploaded files. SQL datasets on those connections don't accept template expressions or dataset inputs.