Which rows belong in the Tableau ledger union?
Count the rows and their quantities on the data-source canvas before creating the first sheet.
Check your reading
Keep the 12 physical observations from counts.csv outside the union. Adding them as movement events would count observed stock a second time.
Open the case files, data dictionary and portfolio challenge
A warehouse records an opening quantity once for each branch-product, then posts signed changes. Each physical count is an observation against which the calculated book can be checked. Applying the opening to every movement or adding the count to the ledger would corrupt the book.
- Download opening.csv, movements.csv, counts.csv and products.csv into one folder. Reserve may-movements.csv for the final challenge. In Tableau Desktop connect to a text file in that folder. On the Data Source page create a manual New Union containing only opening.csv and movements.csv. Use the physical canvas within one logical table if needed. Name the logical table Ledger. Leave counts outside the union.
- Set opening_date to Date, event_time to Date & Time, quantities to whole numbers and identifiers to String. Tableau may prettify names in the Data pane. Rename fields to their source headers or insert the matching field names through the calculation editor. Rows from the opening file have opening_units; movements have units_delta and move_id.
- Create Event delta and Event instant with the calculations below. Check opening rows have a quantity, movements have a nonblank unique move_id and a signed quantity, and no row contains both an opening and a movement. Keep issue quantities negative as supplied.
IF NOT ISNULL([opening_units]) THEN [opening_units] ELSE [units_delta] ENDIF NOT ISNULL([opening_units]) THEN DATETIME([opening_date]) ELSE [event_time] ENDOn an unfiltered sheet COUNT(opening_units) gives 12, SUM(opening_units) gives 312, COUNT(move_id) and COUNTD(move_id) both give 62, and SUM(units_delta) gives +66. The union has 74 rows.