Learn by Directing AI
Unit 4

The Metabase dashboard

Step 1: Connect DuckDB to Metabase

Open Metabase at localhost:3000. You need to connect your DuckDB database so Metabase can query it.

Direct AI to help with the database connection:

Help me connect my DuckDB database to Metabase. I need the connection configured so Metabase can query the unified dataset we built.

Once connected, verify it works. In Metabase, open a new question, choose "Native query" (SQL mode), and run a simple query against the unified dataset. You should see results.

Use SQL mode for every panel you build -- not the visual query builder. The visual builder applies default filters and aggregation that you can't always see. SQL mode gives you full control over every query, and the queries transfer to any BI platform.

Step 2: Build the KPI panel

The first thing Carmen sees every Monday morning is the headline numbers. Open materials/dashboard-layout-template.md for the layout guidance.

KPI cards go at the top of the dashboard: total revenue, total volume in liters, and order count, all for the selected time period.

In Metabase, create a SQL query that returns total revenue in EUR, total volume in liters, and total order count for the unified dataset. Use the exact revenue and volume definitions we wrote in Unit 3.

Create a Metabase "question" for each KPI using SQL mode. Save each one.

The revenue query must use the same SQL definition you wrote and cross-checked. If you copy the definition from the analysis template and AI modifies it when creating the Metabase question, you've lost metric governance. The number on the dashboard must match the number in your definition.

Step 3: Build channel and style panels

Below the KPIs, you need charts that break down the numbers. Two bar charts:

  • Revenue by channel (taproom, distribution, online)
  • Revenue by beer style (sorted by revenue, not alphabetically)

And a trend line: monthly revenue over the twelve months.

Create each as a separate Metabase question using SQL mode. For the revenue-by-style chart, make sure AI sorts by revenue descending. AI commonly sorts alphabetically -- this buries the insight that a few styles dominate.

For the trend line, use the unified dataset grouped by month. If you later add year-over-year comparison, you'll overlay the previous year on this chart.

Step 4: Add and test filters

Filters are a promise to the stakeholder. "You can filter by date range and channel" means the dashboard must work correctly at every filter combination.

Add three filter variables to the dashboard:

  • Date range (default: last 4 weeks)
  • Channel (all, taproom, distribution, online)
  • Beer style (all, or individual styles)

After adding filters, test them. Filter to taproom only. Does the revenue KPI change? Does it match what you know taproom revenue to be from the segmentation analysis?

Now test an edge case: filter to a channel and a beer style that might have zero data (say, distribution + a seasonal beer outside its season). Does the dashboard handle zero results gracefully, or does it break?

AI commonly generates filters that look right at the default view but fail at edge combinations. Every filter combination is a contract with the stakeholder.

Step 5: Check internal consistency

This is the critical verification step. Open two panels that both show revenue. Do they display the same number for the same period and filters?

Extract the SQL query from the revenue KPI card and the revenue-by-channel bar chart. Compare them. Are they using the same revenue definition? Are they applying filters the same way?

If the queries differ -- different WHERE clauses, different aggregation logic, different handling of consignment returns -- fix them. A dashboard where two panels disagree on revenue is a dashboard that destroys trust. Carmen won't know which number to believe.

This is what metric governance means in practice. The definition you wrote in Unit 3 must flow through every panel identically.

Step 6: Assemble the dashboard

Arrange the panels into a coherent dashboard. Follow the layout template:

  • KPI cards at the top (above the fold -- Carmen sees these without scrolling)
  • Trend line in the middle
  • Channel and beer style breakdowns below
  • Filters at the top of the dashboard

Add a dashboard title: "Bona Lluna Weekly Performance." A dashboard with a clear title tells Carmen -- and her sales manager -- what this view is about without explanation.

The dashboard is not a collection of charts. It is a single argument: here is how Bona Lluna's sales channels performed this period, broken down by style and channel, with the ability to drill deeper. The panels relate to each other and build toward that argument.

✓ Check

Check: Filter the dashboard to show only the taproom channel for the last 3 months. Does the KPI revenue number match the sum of the taproom revenue in the beer-style breakdown panel for the same period?