# Workflows for Data Analysts

This guide walks through the workflow a data analyst follows inside Treasure AI Studio — from an ambiguous business question to a polished, exportable dashboard. Every step happens in a single conversation, with the AI handling the tooling transitions so you can focus on the analysis.

Note
The AI orchestrates multiple tools behind the scenes — CLI commands for data exploration, Trino SQL for queries, HTML chart generation for visualization, and file generation for exports. Every tool call is visible and expandable in the chat stream so you can verify each step. See [Agent Orchestrator](/products/ai-studio/concepts/orchestrator) for how the AI plans and executes multi-step workflows.

## Objective

Enable data analysts to go from "What happened to our conversion rate last quarter?" to a validated, stakeholder-ready dashboard in a single session — eliminating the context-switching between query editors, visualization tools, and presentation software that normally fragments analytical work.

## A Day in the Life

You arrive Monday morning to a Slack message from the VP of Product: "Conversion rate seems down. Can you pull together a Q1 performance overview for the leadership meeting at 2 PM?"

Normally this means: open the query editor, remember which tables hold conversion events, write and debug SQL, copy results to a spreadsheet, build charts, paste them into slides. Two hours of context-switching.

In Studio, it's one conversation. You describe the goal, the AI explores the data, writes optimized queries, renders charts, assembles a dashboard, and generates the deck. You steer the analysis — the AI handles the tooling.

## Recommended Setup

Before starting the workflow, configure your environment for maximum efficiency:

| Setup Step | How | Why |
|  --- | --- | --- |
| **Create a project** | Create a project named "Analytics" with your default database in the TD context | Saves you from specifying the database in every query |
| **Activate skills** | Select **trino**, **time-filtering**, and **trino-optimizer** in the Skills dropdown | Teaches the AI your platform's SQL patterns |
| **Choose a model** | Start with **Balanced** (Sonnet); switch to **Pro** (Opus) for complex joins | Balances speed and reasoning quality |


## Step-by-Step Workflow: Q1 Performance Dashboard

### Step 1: Explore the Data

Start by telling the AI what you're looking for, not which tables to query:


```
You: I need to analyze Q1 conversion performance. What data do we have
     related to user signups, purchases, and page views?
```

**What the AI does behind the scenes:**

1. Runs `tdx databases` to list available databases
2. Runs `tdx tables <database>` on your default database (from project settings)
3. Runs `tdx describe` on promising tables to inspect schemas
4. Summarizes what's available and recommends a query approach


**What you see:**


```
AI: [Tool: Bash] tdx databases
    [Tool: Bash] tdx tables marketing_prod
    [Tool: Bash] tdx describe marketing_prod.user_events
    [Tool: Bash] tdx describe marketing_prod.purchases

    I found two relevant tables in marketing_prod:

    | Table | Key Columns | Row Estimate |
    |-------|-------------|-------------|
    | user_events | user_id, event_type, time | ~45M rows |
    | purchases | user_id, amount, product_id, time | ~2.1M rows |

    user_events contains signup, page_view, and add_to_cart events.
    I can calculate conversion as signups → purchases. Shall I proceed?
```

Pro Tip
If you already know your tables, skip exploration: "Query `marketing_prod.user_events` and `marketing_prod.purchases` for Q1 conversion." The AI skips discovery and jumps straight to query construction.

### Step 2: Run the Analysis Queries

Confirm the approach and let the AI write the SQL:


```
You: Yes, calculate daily conversion rate (signups to purchases) for Q1.
     Break it down by week and by traffic source.
```

**What the AI does:**

1. Constructs a Trino query using `td_interval()` for Q1 date filtering (guided by the **time-filtering** skill)
2. Joins `user_events` and `purchases` on `user_id`
3. Applies partition pruning for performance (guided by the **trino** skill)
4. Runs the query via `tdx query`


**What you see:**


```
AI: [Tool: Bash] tdx query -e trino "
      SELECT
        TD_TIME_FORMAT(e.time, 'yyyy-ww') AS week,
        e.source AS traffic_source,
        COUNT(DISTINCT e.user_id) AS signups,
        COUNT(DISTINCT p.user_id) AS purchasers,
        ROUND(COUNT(DISTINCT p.user_id) * 100.0
              / NULLIF(COUNT(DISTINCT e.user_id), 0), 2) AS conversion_rate
      FROM marketing_prod.user_events e
      LEFT JOIN marketing_prod.purchases p
        ON e.user_id = p.user_id
        AND TD_INTERVAL(p.time, '-90d')
      WHERE e.event_type = 'signup'
        AND TD_INTERVAL(e.time, '-90d')
      GROUP BY 1, 2
      ORDER BY 1, 2
    "

    Here are the results:

    | Week | Source | Signups | Purchasers | Rate |
    |------|--------|---------|------------|------|
    | 2026-01 | organic | 1,240 | 186 | 15.0% |
    | 2026-01 | paid | 890 | 98 | 11.0% |
    | ... | ... | ... | ... | ... |

    Conversion rate dropped from 15% in January to 11.2% in March,
    with paid traffic showing the steepest decline.
```

### Step 3: Visualize the Results

Now ask for the visualization:


```
You: Show me the weekly conversion trend as a line chart,
     with separate lines for each traffic source.
```

**What the AI does:**

1. Formats the query results into the chart data structure (labels + datasets)
2. Generates a self-contained HTML file with the chart and opens it via `open_file`
3. Chart appears in the file panel


**What you see:**

A line chart in the file panel with:

- X-axis: weeks (2026-01 through 2026-13)
- Y-axis: conversion rate (%)
- Lines: one per traffic source, color-coded
- Tooltips on hover showing exact values



```
You: The paid drop is steeper than I expected. Can you add a scatter plot
     showing spend vs. conversion for paid traffic?
```

The AI runs a follow-up query joining cost data, then renders a scatter chart. You now have two charts in the file panel.

### Step 4: Build a Dashboard

Coming Soon
Grid dashboards are a planned feature. The workflow described in this step is not yet available in the current release. You can still ask the AI to generate individual charts and tables as separate files.

With the analysis complete, assemble everything into a grid dashboard:


```
You: Build a dashboard with:
     - KPI cards for overall Q1 conversion, total signups, and total revenue
     - The conversion trend line chart
     - A bar chart of conversion by source
     - A table of the top 10 underperforming weeks
```

**What the AI does:**

1. Runs additional queries to calculate KPI totals
2. Generates an HTML file with a multi-cell grid layout (KPIs across the top row, charts in the middle, table at the bottom)
3. Opens the file in the file panel


**What you see:**

An interactive dashboard with:

- Three KPI cards showing total metrics with trend arrows
- Line chart and bar chart side by side
- Sortable table at the bottom with week-by-week detail


Pro Tip
Dashboards will support multiple pages. Ask the AI to "add a second page for regional breakdown" and a page selector dropdown appears at the top of the dashboard.

### Step 5: Debug a Slow Query

During your analysis, a query takes too long. The AI helps you optimize:


```
You: That last query took 3 minutes. Can you optimize it?
```

**What the AI does (guided by the trino-optimizer skill):**

1. Analyzes the slow query's structure
2. Identifies missing partition pruning or expensive joins
3. Rewrites the query using optimization patterns (CTAS for intermediate results, `APPROX_DISTINCT` for large cardinality, `REGEXP_LIKE` instead of multiple `LIKE` clauses)
4. Runs the optimized version and reports the speedup



```
AI: The original query scanned all partitions. I've rewritten it with
    explicit TD_TIME_RANGE bounds and moved the join to a CTE:

    [Tool: Bash] tdx query -e trino "WITH signups AS (...) ..."

    Execution time: 12 seconds (was 3 minutes).
    The main improvement was partition pruning — the original WHERE clause
    didn't use TD_INTERVAL on the purchases table.
```

### Step 6: Export Deliverables

With the analysis complete, generate the deliverable for the 2 PM meeting:


```
You: Create a PowerPoint deck with these findings for the leadership meeting.
     Include the charts, key takeaways, and a recommendation slide.
```

**What the AI does:**

1. Structures a PPTX with slides: title, executive summary, conversion trend chart, source breakdown, underperforming weeks table, and recommendations
2. Writes the file to the working directory
3. A file card appears in the chat with Preview and Download buttons



```
You: Also export the raw data as an Excel file with separate sheets
     for weekly metrics and source breakdown.
```

**What the AI does:**

1. Formats the query results into a multi-sheet XLSX structure
2. Writes the file
3. Another file card appears, ready for download


## Workflow Variations

The Q1 dashboard is one pattern. Here are other common analyst workflows in Studio:

### Data Quality Audit


```
You: Audit the customer_profiles table for data quality issues —
     check for nulls, duplicates, and stale records.

AI: 1. [Bash] tdx describe marketing_prod.customer_profiles → schema
    2. [Bash] tdx query → NULL counts per column
    3. [Bash] tdx query → duplicate user_id detection
    4. [Bash] tdx query → staleness (records not updated in 90 days)
    5. [open_file] Bar chart of null rates by column
    6. [Text] Summary with prioritized remediation steps
```

### Pipeline Debugging


```
You: The daily_etl workflow failed last night. What happened?

AI: 1. [Bash] tdx wf sessions daily_etl → find failed session
    2. [Bash] tdx wf attempt logs <session_id> → read error logs
    3. [Thinking] Root cause: table not found (schema change)
    4. [Write] Updated .dig file with fix
    5. [Text] Explanation + recommendation to add _retry block
```

### Ad-Hoc Exploration


```
You: I just got access to the new clickstream_raw table.
     What's in it and is it useful for attribution modeling?

AI: 1. [Bash] tdx describe clickstream_raw → schema + sample
    2. [Bash] tdx query → row counts, date ranges, event types
    3. [Bash] tdx query → cardinality of key dimensions
    4. [open_file] Distribution of event types
    5. [Text] Assessment: suitable for multi-touch attribution,
             recommended join strategy with purchases table
```

## AI Transparency: How the Orchestrator Works

Throughout this workflow, the AI is making decisions you can see and influence:

| AI Decision | What You See | How to Override |
|  --- | --- | --- |
| **Which tables to query** | `tdx describe` tool calls in the chat | "Use `analytics.events` instead" |
| **SQL syntax and functions** | Full query visible in the Bash tool card | "Use Hive instead of Trino" or "Add a WHERE clause for region = 'US'" |
| **Chart type selection** | Chart HTML file visible via open_file call | "Show this as a bar chart, not a line chart" |
| **Dashboard layout** | YAML file visible via Write tool call | "Put the KPIs in a 3-column row at the top" |
| **Optimization strategy** | Rewritten query visible alongside original | "Keep the original structure but add partition pruning" |


The AI follows active skills (Trino, time-filtering, trino-optimizer) for platform-specific patterns, but you always have final say. Every tool call is expandable — click to see the exact command and result.

## Success Criteria: The Business Result

At the end of this workflow, you have:

- **A validated analysis** — Every number is traceable to a specific query visible in the chat
- **Interactive visualizations** — Charts with tooltips and legends that you can present during screen-share
- **A stakeholder-ready dashboard** — Multi-cell grid with KPIs, charts, and tables
- **Exportable deliverables** — PPTX deck and XLSX data file ready for download
- **An auditable trail** — The full conversation serves as documentation of your analytical process


All produced in a single session, without switching between query editors, BI tools, and slide builders.

## Verification

After following this workflow, you can:

- [ ] Explore an unfamiliar database using natural language and the AI's `tdx describe` calls
- [ ] Request and receive optimized Trino SQL with TD-specific functions
- [ ] Generate a chart from query results and customize its type
- [ ] Build a multi-cell grid dashboard with KPIs, charts, and tables
- [ ] Export results as PPTX and XLSX for stakeholder delivery
- [ ] Trace every number back to the tool call that produced it


## Troubleshooting

| Issue | Solution |
|  --- | --- |
| AI writes SQL that references non-existent tables | Start by asking the AI to run `tdx databases` and `tdx tables` to confirm available tables. Provide the database and table names explicitly in your prompt |
| Chart does not render after query | Ensure the query returned data — expand the tool call to check. If the result set is empty, adjust your query filters |
| Dashboard cells are empty | Grid dashboards require the AI to populate each cell. Ask the AI to "fill in the KPI cells with values from the query" if cells appear blank |
| Export fails or produces an empty file | Confirm the data is available in the current session. If context was compacted, the AI may need to re-run queries before exporting |


## Next Steps

- [Agent Orchestrator](/products/ai-studio/concepts/orchestrator) — Understand the AI's decision-making in depth
- [Charts & Data Visualization](/products/ai-studio/visualization/charts) — Full reference for chart types and dashboards
- [Query Execution](/products/ai-studio/query/query-execution) — Deep dive into Trino query mechanics
- [Skills & Marketplace](/products/ai-studio/skills/skills) — Configure SQL and optimizer skills
- [File Output](/products/ai-studio/files/artifacts) — All file export formats and viewer capabilities