Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions guides/ai-agents/using-ai-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AI agents in Lightdash allow you to:
- **Guide you to the right data** - Direct you to the most relevant explores or tables for your questions
- **Discover existing content** - Find and share relevant charts and dashboards that have already been created in your project
- **Generate complete dashboards** - Create multiple related visualizations at once that tell a cohesive story about your data, perfect for executive summaries or thematic analyses
- **Compare across time periods** - Ask for month-over-month, year-over-year, or any custom period offset, and the agent adds a comparison column next to each metric automatically

As mentioned earlier, Lightdash agents use the **semantic layer** defined in your dbt models to understand your data structure, relationships, and business logic.
This ensures that the AI generates accurate queries and visualizations based on your specific data context.
Expand Down Expand Up @@ -51,6 +52,30 @@ If your agent has data access disabled, pinning still works — the agent sees t

## Example use cases

### Period-over-period comparisons

Agents can answer time-comparison questions directly — month-over-month, year-over-year, or any custom offset — without you having to set up the comparison in the Explorer first.

When you ask a comparison question, the agent picks a base metric, a time dimension, a granularity (day, week, month, quarter, or year), and an offset (how many periods back). It then runs the query and adds a comparison column next to the base metric, labelled with the offset (for example, `Revenue (Previous month)`).

**Prompts that work well**

- *"Compare revenue to last month"*
- *"Month-over-month new users"*
- *"Year-over-year orders by week"*
- *"Show revenue this quarter vs the previous quarter, and vs the same quarter last year"*

You can stack multiple comparisons on the same metric (for example, MoM and YoY together) and you can use a [custom metric](/references/custom-fields) as the base.

<Tip>
Period-over-period is for comparing whole prior periods (last month, last quarter, last year). For period-to-date questions like MTD or YTD, ask the agent for a filtered aggregation instead — for example, *"revenue so far this month vs the same point last month"*.
</Tip>

**Limitations**

- The granularity must match the time dimension's interval — ask for *"monthly revenue vs last month"* (not *"daily revenue vs last month"*).
- The agent can't yet sort or filter on the generated comparison column directly; sort or filter on the base metric or the time dimension instead.

### Advanced visualizations with window functions

AI agents can handle complex analytical queries that would traditionally require writing intricate SQL or YAML configurations. In this example, we demonstrate building a 3-month rolling average visualization using nothing but natural language.
Expand Down
4 changes: 4 additions & 0 deletions guides/period-over-period.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ To add a period comparison:
4. Choose the time dimension and offset, then hit save
5. Add the generated metric to your chart

<Tip>
You can also ask an [AI agent](/guides/ai-agents/using-ai-agents#period-over-period-comparisons) for comparisons in natural language — for example, *"compare revenue to last month"* or *"year-over-year orders by week"*.
</Tip>

---

Period-over-period analysis is one of the most common ways to evaluate how metrics change over time. Whether you're looking at **month-over-month growth**, **year-over-year comparisons**, or **week-over-week performance**, Lightdash makes it easy to build these analyses directly in your dashboards.
Expand Down
Loading