A Table is the starting point for querying data in Lightdash. It groups related dbt models with the dimensions and metrics defined on them, and you query it in the Explore view.
To start a query, click [+] New → Query from tables, then pick the table you want to explore.
The Explore page
The Explore page is made up of five areas:
- Metrics and dimensions available on the table you selected
- Filters, which restrict the data in your query
- Chart, where you visualize the results
- Results, the raw data returned from your database
- SQL, the generated SQL that produced the results
Select your fields
To run a query:
- Select a metric to calculate.
- Select one or more dimensions to split the metric into groups.
- Hit Run query in the top right.
For “number of orders per month split by partner”, that’s the Order count metric with the Order month and Partner name dimensions.
Filter results
Filters restrict the rows your query returns. You can add them from the Filters section, from a column header in the results table, or from the field list in the sidebar — see filtering in the Explore view.
Sort results
Click the arrow in the table header for the field you want to sort by.
To sort by multiple fields, click the blue pill showing the current sort, then choose + Add sort.
The sort menu behaves like this:
- Adding a sort by clicking a column header overwrites any previous rules.
- Once you’re sorting by multiple columns, you can drag and drop them to rearrange the order.
- Remove a sort by clicking the
X to its right.
- Change the direction of a column’s sort with the toggle next to its field name.
Sorting NULL values
You can specify whether NULL values appear first, last, or follow your database’s default.
- Open the sort menu by clicking the blue pill that displays the current sort.
- For each sort field, use the NULL sorting control to pick Nulls first, Nulls last, or Default.
The choice is applied to the generated SQL as a NULLS FIRST or NULLS LAST clause in the ORDER BY statement.
Build a chart
Once the query runs, your data appears in the results table. Open the Chart section and choose a chart type — see chart types and configurations.
Save your chart
Saving a chart lets you share it, add it to a dashboard, or come back to it later. A saved chart re-runs its query every time you open it, so it always shows the latest data in your database.
Click Save chart at the top of the page, then give the chart a useful name and description. You’ll have the option to save it to a dashboard or a space.
Once a chart is saved, it unlocks:
Saving to a dashboard
Most charts in Lightdash are saved directly to a dashboard. This is the better option when a chart is only ever going to be used on one dashboard, and it keeps your spaces free of long lists of charts that only make sense in one context.
A chart saved to a dashboard lives only in that dashboard. To reuse it, move it to a space, or click Explore from here and save a new version of the chart.
Saving to a space
A chart saved to a space can be shared on its own and reused across multiple dashboards. It’s also the only way to pin a single chart to your project home page.
You get a saved chart view you can share with others.
Explore from an existing chart
Saved charts and dashboard tiles make good starting points for exploration. Explore from here gives you a copy of the same chart to play with, and nothing you do to it affects the original — so you can explore without worrying about breaking anything.
Changing the explore of an existing chart
Once a chart is saved, you can switch the explore (table) it’s built on without recreating it. Open the saved chart, open the Change explore dialog, and pick the new explore; all field references are remapped to it.
Tick Also update all other charts using this explore to remap every chart built on the current explore in one go — useful when an entire model is being replaced.
Fields that exist on the new explore with the same field IDs are kept; anything that doesn’t exist there is dropped, and you’ll need to re-pick the missing fields before saving.
A handy use case is migrating charts from one model to another — for example, when you rename a dbt model or replace it with a different version. Instead of rebuilding the charts from scratch, point them at the new explore and keep the configuration that still applies.