T1 lab: Can we trust the sales table, in Tableau?¶
Connect Tableau to the Superstore file, set the same scope as the Python sessions, and prove you can count rows, orders and returned orders correctly. Then draw the shape of order value and delivery time.
This lab rebuilds parts of the Session 2 lab and the Session 4 lab in Tableau. If you get stuck, look back at how you did the same step in Python.
Desktop and web editor
The click paths on this page are written for Tableau Desktop Public Edition. If you use the Tableau Public web editor in a browser, the menus differ slightly. Look for the same command in a nearby menu, or ask your facilitator.
The business decision¶
The head of a retail business says:
"Before you show me any chart in this new tool, can I trust it? Does Tableau give the same number of orders and returns as your earlier analysis? And what does a typical order and a typical delivery look like?"
A new tool is a new chance to count the wrong thing. Today you set up the data carefully and check every number by reconciliation: the parts must add up to the total.
About the data
Superstore is a sample published by Tableau about a fictitious company. Sales and Profit are in the file's own monetary units. The file does not state a currency, so we never call them dollars or any other currency.
How this lab works¶
| Part | What you do | Tasks |
|---|---|---|
| Setup | Connect to the file and set the course scope, everyone together | Setup |
| Core | Count rows, orders and returned orders; build a filtered bar chart; save | C1–C4 |
| Stretch | Draw distributions of order value and ship days | S1–S2 |
| Challenge | Check one order by hand; fix a colleague's summary | X1–X2 |
Each task has a level:
- Core: everyone completes it; it is enough for your portfolio.
- Stretch: for when you finish the core tasks early.
- Challenge: optional, harder reasoning.
What you will be able to do¶
- Connect Tableau to an Excel file and relate two of its sheets.
- Set a data source filter so every sheet uses the course scope.
- Count order lines and orders and explain why they differ.
- Count returned orders and reconcile them with the total.
- Build a bar chart with a filter, and check that its parts add up.
- Save your work as a packaged workbook (
.twbx).
Evidence you keep: your saved workbook, a rows-versus-orders table, a returned-orders table, a filtered bar chart and your reconciliation notes.
Before you start, work through the T1 lecture. Have the downloaded sample_-_superstore.xls file and your evidence log ready (see the Tableau overview).
Set up the Superstore data source¶
Later labs (T2 and T3) start from this setup, so take care with each step.
Use the downloaded file, not the built-in sample
Tableau Desktop Public Edition has a built-in data source called Sample - Superstore. It may be a different version of the data. Always connect to the sample_-_superstore.xls file you downloaded, so your numbers match the course and your Python work.
Step 1: Connect to the file¶
- Open Tableau Desktop Public Edition.
- In the Connect pane on the left, under To a File, click Microsoft Excel.
- Find and open
sample_-_superstore.xls. - Tableau opens the Data Source page. On the left, under Sheets, you see Orders, People and Returns.
Step 2: Add the Orders sheet¶
- Drag Orders onto the large empty area (the canvas) at the top.
- A preview of the rows appears below. Look at the small icon above each column: Abc for text, # for numbers and a calendar for dates.
Check the IDs
Order ID should show Abc (text). Row ID shows #, but it is an identifier, not an amount. You will never add it up.
Step 3: Relate Returns to Orders on Order ID¶
- Drag Returns onto the canvas, next to Orders.
- Tableau draws a line between the two boxes. This line is a relationship.
- Click the line. In the panel that opens below, check that the matching fields are Order ID (Orders) = Order ID (Returns). If they are not, choose Order ID in both lists.
- Close the panel.
What the relationship does
The Returns sheet lists each returned order once. The relationship lets Tableau look up whether an order's Order ID is on that list. It does not change the Orders sheet.
Step 4: Add the course scope as a data source filter¶
- At the top right of the Data Source page, under Filters, click Add.
- In the Edit Data Source Filters window, click Add....
- Choose Order Date (from the Orders table) and click OK.
- Choose Range of Dates and click Next.
- Set the start date to 1 January 2023 and the end date to 31 December 2025. Both dates are included.
- Click OK, then OK again.
The Filters area now shows 1 filter. Every sheet in this workbook will use only orders placed from 2023 to 2025, the same scope as the Python sessions.
Check the date format
Tableau shows dates in your computer's format. 01/12/2025 can mean 1 December or 12 January. Read the dates back after you type them.
Step 5: Create the Returned Order field¶
- Click the Sheet 1 tab at the bottom of the window.
- In the Data pane on the left, you now see two tables: Orders and Returns. The Order ID from Returns is shown as Order ID (Returns).
- Choose Analysis → Create Calculated Field....
-
Name the field
Returned Orderand type this formula:NOT ISNULL([Order ID (Returns)]) -
Check that the message under the formula says The calculation is valid, then click OK.
In plain words: an order is returned when Tableau finds its Order ID on the Returns sheet.
Step 6: Save straight away¶
- Choose File → Save As.
- Choose your course folder and save as a Tableau Packaged Workbook (*.twbx) named
T1_lab_YourName.
Save again (Ctrl + S on Windows, Cmd + S on Mac) after each task.
Core tasks¶
C1 (Core): Rows versus orders¶
The (Count) field counts rows. In Superstore one row is one order line, so this is not the number of orders.
- Rename Sheet 1 to
Rows vs orders: double-click the tab and type the new name. -
Create a calculated field named
Distinct Orderswith this formula:COUNTD([Order ID]) -
In the Data pane, double-click Orders (Count). Tableau shows one number: the number of order lines.
- Double-click Distinct Orders. Tableau now shows both numbers in a small table, labelled by Measure Names.
- Write both numbers in your evidence log.
- Write one sentence explaining why the two numbers differ.
Another way to count orders
You can also drag Order ID into the view, right-click its pill and choose Measure → Count (Distinct). The Distinct Orders field saves you doing this every time.
Compare with Python
Check your two numbers against the rows and orders you found in the Session 2 lab. They should be the same. If they are not, check the data source filter in Step 4 first.
C2 (Core): Returned orders¶
- Create a new sheet: click the New Worksheet icon next to the sheet tabs. Name it
Returned orders. - Drag Returned Order to Rows.
- Drag Distinct Orders to Text on the Marks card.
- You see True for orders on the Returns sheet. The other orders show as False or as Null, depending on how Tableau matches the two tables. Both mean "not on the Returns sheet".
- Choose Analysis → Totals → Show Column Grand Totals.
Reconcile:
- Add the two numbers by hand. Do they equal the Grand Total?
- Is the Grand Total the same as Distinct Orders in C1?
Now swap Distinct Orders for Orders (Count). The number next to True gets bigger. In one sentence, explain what it is counting now and why it is not the number of returned orders.
Returned means on the list
The Returns sheet has no return date, quantity or refund amount. An order that is not on the list is not proof that nothing came back. Write "orders on the returns list" when you report this number.
C3 (Core): Orders by segment, with a filter¶
- Create a new sheet named
Orders by segment. - Drag Segment to Rows and Distinct Orders to Columns. You get one bar per segment.
- Click the Sort descending icon in the toolbar so the longest bar is at the top.
- Drag Distinct Orders onto Label on the Marks card, so each bar shows its value.
- Choose Analysis → Totals → Show Column Grand Totals.
- Double-click the sheet title and write a title that says what the chart shows and for which period, for example
Orders by customer segment, orders placed 2023–2025.
Reconcile: add the three segment bars by hand. Do they equal the Grand Total, and the Distinct Orders number from C1?
Now add a filter:
- Drag Region to the Filters shelf.
- In the window that opens, tick one region only and click OK.
- Right-click the Region pill on the Filters shelf and choose Show Filter. A filter control appears on the right.
- Add your region to the title, for example
... (Region: West). - Add up the segment bars again. Do they still equal the new Grand Total?
- Switch the filter back to (All) before you move on.
Write your filters down
Every time you filter, record it in your evidence log. A chart without its filters written down is easy to misread later.
Think about it. Make a copy of the sheet (right-click the tab → Duplicate) and replace Segment with Category. Add the category bars by hand. Do they equal the Grand Total this time? Write one sentence on why not. Hint: can one order contain products from more than one category? Can one order belong to more than one segment?
C4 (Core): Save and reopen¶
- Save your workbook (File → Save).
- Close Tableau completely.
- Open Tableau again and open
T1_lab_YourName.twbx. - Check that all your sheets, the Returned Order and Distinct Orders fields and the data source filter are still there.
Stretch tasks¶
S1 (Stretch): Histogram of order value¶
To describe orders, you first need the value of each order, not each line. In Session 4 you built an order-level table in Python. In Tableau you create an order total field.
- Create a new sheet named
Order value. -
Create a calculated field named
Order Total:{ FIXED [Order ID] : SUM([Sales]) }In plain words: for each Order ID, add up the Sales of all its lines. Every line of an order then carries that order's total. You learn how this kind of formula works in T2.
-
In the Data pane, right-click Order Total and choose Create → Bins....
- Choose a round Size of bins, for example
100, and click OK. A new field Order Total (bin) appears. - Drag Order Total (bin) to Columns and Distinct Orders to Rows.
- Title the chart, for example
Order value, orders placed 2023–2025 (file's own monetary units).
Count orders, not rows
Every line of an order carries the same Order Total. If you used Orders (Count) on Rows, an order with three lines would be counted three times. Distinct Orders counts each order once.
Reconcile: every order falls in exactly one bin, so the bars must add up to Distinct Orders.
- Drag Distinct Orders onto Label on the Marks card.
- Right-click that Label pill and choose Quick Table Calculation → Running Total. Each label now adds its bar to all the bars before it. You meet running totals properly in T2.
- Read the label on the last bar. Does it equal Distinct Orders from C1?
- Right-click the Label pill and choose Clear Table Calculation.
Read it. In one or two sentences, describe the shape. Where are most orders? Is there a long tail to one side? Does it match the histogram you drew in the Session 4 lab?
S2 (Stretch): Box plot of ship days by ship mode¶
- Create a new sheet named
Ship days. -
Create a calculated field named
Ship Days:DATEDIFF('day', [Order Date], [Ship Date])In plain words: the number of days from the order date to the ship date.
-
Drag Ship Mode to Columns and Ship Days to Rows.
- Tableau shows SUM(Ship Days). Right-click the pill and choose Measure → Average.
- Drag Order ID onto Detail on the Marks card. You now have one mark per order.
- In the Marks card drop-down, choose Circle.
- Right-click the vertical axis and choose Add Reference Line. At the top of the window, choose Box Plot, then click OK.
- Title the chart, for example
Days from order to shipment by ship mode, orders placed 2023–2025.
Why Average and not Sum?
Every line of an order has the same Order Date and Ship Date, so the same Ship Days. The average of identical values is that value. SUM would add it once per line and make orders with more lines look slower.
Hover over a box to see its median and quartiles.
Read it. Which ship mode is fastest? Which has the widest spread? Write one sentence a customer service lead could use when making a delivery promise. Compare with the ship-days results in the Session 4 lab.
Challenge tasks¶
X1 (Challenge): Check one order by hand¶
A total you cannot check is a total you cannot trust. Pick one order and reconcile its lines.
- Create a new sheet named
One order. - Drag Order ID to Rows and Orders (Count) to Text.
- Click the Sort descending icon in the toolbar, so orders with the most lines are at the top.
- Right-click one Order ID with several lines and choose Keep Only.
- Drag Product Name to Rows, after Order ID. Drag Sales to Text, replacing Orders (Count).
- Choose Analysis → Totals → Show Column Grand Totals.
- Add the line Sales yourself, with a calculator or on paper.
Reconcile three numbers and write them in your log:
- your hand total,
- Tableau's Grand Total for the order,
- the Order Total field from S1 for this order (drag it to the view and set it to Minimum or Average; every line has the same value).
Do all three agree? Also check that Segment, Ship Mode and Ship Days are the same on every line of the order.
X2 (Challenge): Fix a colleague's summary¶
A colleague sends this summary:
"We had [Orders (Count) for all data] orders, and [Orders (Count) for Returned Order = True] of them were returned."
- Which two mistakes are in this sentence?
- Which field should each number use instead?
- How would you check your corrected numbers? Name the reconciliation.
Write your corrected sentence in your log. Remember the wording from C2: "on the returns list".
Evidence checklist¶
Before you submit, check that you have:
- the data source set up with the Returns relationship and the 2023–2025 data source filter
- the
Rows vs orderssheet, with your sentence on why the numbers differ - the
Returned orderssheet, with your reconciliation note - the
Orders by segmentsheet with a title, a Region filter and your reconciliation note - your sentence on why category orders do not add up to the total
- Stretch and Challenge sheets, if you did them
Submit on Moodle¶
- Save your workbook as
T1_lab_YourName.twbx(File → Save). - Export your
Orders by segmentsheet: choose File → Print to PDF, or Worksheet → Export → Image.... - Open the T1 lab assignment on the course Moodle page.
- Upload the
.twbxfile, the PDF or image, and your written answers (from your evidence log).
Do not publish this lab
You do not need to publish anything to Tableau Public for this lab. Anything published there is public. If you use the web editor, saving puts the workbook and its data on your Tableau Public profile. Keep your Superstore work on your own computer: never save or publish Superstore to Tableau Public, because the course has not found a clear permission to republish the file (T4 lecture, Part 2). Ask your facilitator how to work on this lab without saving to Tableau Public, and how to get your workbook for Moodle.
Next¶
Keep this workbook. In T2 you start from the same data source to build KPIs and growth rates.