Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 35 ยท Projects

Project: Sales Performance Dashboard in Tableau

Build a Tableau sales dashboard step by step: KPIs, year-over-year, margin, top products, filters and actions, with SQL that checks every number you show.

In this project you build a Sales Performance Dashboard, the kind of one-page view an executive opens every Monday. You will plan the questions, shape the data, write the calculated fields, build five sheets, assemble the dashboard with filters and actions, and check every number. Skills come from the earlier chapters of the course, and the steps link to the lessons that explain them.

Tableau Desktop is a graphical program and cannot run in the browser, so the build steps are written as instructions you follow in Tableau, and the Tableau calculations are read-only code blocks. The runnable SQL is a stand-in: it builds the same small data set and computes every figure the dashboard should show. In a real project, that independent check is your reconciliation, the best defence against a wrong join or calculation.

The brief

A furniture company wants a one-page dashboard that answers:

  1. How much did we sell, and how profitable is it? (KPIs)
  2. How does this year compare with last year? (year over year)
  3. How is sales building up month by month? (trend)
  4. Which categories and products drive sales and margin? (ranking)
  5. Which regions underperform? (comparison)

The plan

KPIs Sales, profit, margin, orders.
Trend Months and year over year.
Ranking Top products and categories.
Check Every number reconciled.
1 / 2

Step 1: the data

The data is one table of order lines: order ID, date, region, category, product, sales, profit and quantity. In Tableau you would connect to a database or an Excel file (see the Connecting to Data chapter); a single flat table keeps the project simple. The block creates the table and verifies the grain: one row per order line, no duplicates.

SQL Create the data and check its grain

Press Run (or Ctrl + Enter) to see the result here.

15 rows, 15 unique lines, 14 orders (order 101 has two lines). Knowing the grain tells you that SUM([Sales]) is safe but COUNT([Order ID]) counts lines; you need COUNTD([Order ID]) for orders.

Step 2: calculated fields

Create these in Tableau (Analysis > Create Calculated Field). They are read-only here, because the Tableau formula language cannot run in the browser:

Text
// Profit Margin  (ratio of sums, never an average of ratios)
SUM([Profit]) / SUM([Sales])

// Orders
COUNTD([Order ID])

// Sales This Year (current year in the data)
SUM(IF YEAR([Order Date]) = { MAX(YEAR([Order Date])) } THEN [Sales] END)

// Sales Last Year
SUM(IF YEAR([Order Date]) = { MAX(YEAR([Order Date])) } - 1 THEN [Sales] END)

// YoY Growth
([Sales This Year] - [Sales Last Year]) / [Sales Last Year]

// Margin Flag (for colour)
IF [Profit Margin] < 0.12 THEN "Low" ELSEIF [Profit Margin] < 0.2 THEN "OK" ELSE "High" END

The LOD expression { MAX(YEAR([Order Date])) } makes the "current year" a fixed value that does not change when filters are applied; recall from Order of Operations and Filter Pitfalls that FIXED-type expressions ignore dimension filters. A less fragile alternative is a parameter for the year.

Step 3: the headline numbers

The first sheet is a row of KPI tiles: total sales, profit, margin, orders and YoY growth. Here are the numbers to expect. For comparability the stand-in compares the same months (January to June) in both years, the honest "same period" comparison.

SQL KPIs and same-period year over year

Press Run (or Ctrl + Enter) to see the result here.

For the full years, 2024 sold 4,250 (profit 740, margin 17.4%) and 2025 sold 5,260 (profit 898, margin 17.1%), but 2025 only runs to June. The same-period table gives the fair comparison: January to June 2024 sold 3,550 against 5,260 in January to June 2025, a growth of 48.2%. This is why the Sales Last Year calculation should be limited to the same months, for example by adding AND DATEPART('dayofyear', [Order Date]) <= DATEPART('dayofyear', TODAY()) to the IF condition, or by filtering both years to the same date range.

Year-over-year on a part-year is the most common mistake on sales dashboards. Always compare equal periods, and label the dashboard "Year to date".

Step 4: the sheets

Build five worksheets (see the Building Views chapter for each chart type):

  1. KPI tiles: three text sheets showing SUM([Sales]), [Profit Margin] and [YoY Growth], formatted as currency and percent, with the margin tile coloured by [Margin Flag].
  2. Monthly trend: a continuous Month(Order Date) on Columns, SUM([Sales]) on Rows, a line per year (use YEAR on Color with a discrete year, and the month as a month number so the years overlay). Add a trend line if you like.
  3. Sales by category: horizontal bars sorted descending, coloured by margin; add a reference line at the average (reference lines).
  4. Top 5 products: bars with a Top N filter on Product. If you filter by region too, put Region in Context so the Top N respects it.
  5. Region comparison: a bar chart (or a map if regions are geographic) of margin by region.

Here are the checks for sheets 3 to 5:

SQL Numbers behind sheets 3, 4 and 5

Press Run (or Ctrl + Enter) to see the result here.

Furniture leads on sales (5,520) but its margin of 12.8% trails Technology (21.6%); the Office category is small (590) but earns a strong 33.7%. By product, Desk (3,450) just ahead of Phone (3,400) tops the ranking. Regions are close on sales and margin (West 16.6%, East 17.1%, North 18.0%), so the story is the category mix, not the region. These findings become the captions of your dashboard.

Step 5: the dashboard

  1. Dashboard > New Dashboard, set the size to a fixed 1200 x 800 (faster and predictable; see Extracts and Performance Tuning).
  2. Use horizontal and vertical containers: a KPI row at the top, trend on the left under it, ranking sheets on the right.
  3. Add a Year or Region filter, set to Apply to Worksheets > Selected Worksheets (the ones that use the same data), and use Floating only for legends.
  4. Add actions (Dashboard > Actions): a Filter action from the category bars to the other sheets (select to filter), and a Highlight action from the legend. Add a Go to URL or sheet action for drilling into a detail sheet.
  5. Add a title with the data source and refresh date, and a short caption for each chart that states the finding ("Furniture margin trails Technology by 9 points").
  6. Check Device Preview for phones, and hide filters that don't fit.

Step 6: reconcile before you share

Before publishing (Publishing to Tableau Cloud and Server), run the numbers through an independent check. Compare three figures: total sales, total profit and order count against the SQL (or a database query) result, and confirm that the filters change the dashboard the way you expect. The script below shows a tolerance-based comparison you can reuse: paste the Tableau figures into it.

Python Reconcile Tableau against the source

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Replace the numbers with your own and the same table works for any dashboard. Make this step part of every release.

Extensions

  • Add a forecast for the next three months.
  • Add a parameter for the margin threshold used by the Margin Flag.
  • Add row-level security so each regional manager sees only their region (Permissions and Row-Level Security).
  • Publish the data as a published data source and build the dashboard on it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is a year-over-year comparison of 2025 (January to June) with the whole of 2024 unfair?

    Compare equal periods, for example the same months in both years, or year to date.
  2. 2. How do you count orders when the data has one row per order line?

    COUNTD counts distinct order IDs; COUNT would count every line.
  3. 3. Where should the Margin be computed in Tableau?

    A ratio of sums weights each row correctly; an average of ratios does not.
  4. 4. What is the purpose of the reconciliation step?

    Independent checks catch wrong joins, filters and calculations before anyone relies on them.

Summary

  • Plan the questions first: KPIs, year over year, trend, ranking and region comparison.
  • Know the grain of the data, and use COUNTD and ratios of sums.
  • Compare equal periods in year-over-year; use a fixed dashboard size; add filter and highlight actions.
  • Reconcile the dashboard's numbers with an independent calculation before sharing.
  • The SQL and pandas blocks are stand-ins that compute what the Tableau sheets should show.

Next: Project: Customer Cohort and Retention Analysis