Tableau Data Analyst study materials
Tableau Data Analyst study resources

The Case of the Missing Rows: When a Join Silently Drops Records

Tableau Data Analyst · Put your knowledge to work in context.

All case studies

The Case of the Missing Rows: When a Join Silently Drops Records

A data analyst at a retail company connects Tableau Desktop to a SQL Server database. The primary table, Orders, contains 1,200,000 rows. A secondary table, Customers, contains 150,000 rows. The analyst creates an inner join on CustomerID. After the join, the row count in Tableau is 1,150,000. The analyst knows that every order should have a valid customer, but 50,000 orders are missing. The database administrator confirms that Customers has no duplicate CustomerID values and that all CustomerID values in Orders exist in Customers. However, the CustomerID field in Orders is stored as an integer, while in Customers it is stored as a string with leading zeros (e.g., '00123' vs. 123). The analyst needs to produce a dashboard showing total sales by customer segment, but the missing rows would understate sales by approximately 4%.

1. What is the most likely cause of the missing rows, and how should the analyst resolve it within Tableau?

Read the worked answer

The missing rows are due to a data type mismatch in the join key. Tableau performs joins based on the underlying data types; an integer 123 will not match a string '00123'. Even though the values represent the same customer, Tableau treats them as different. The analyst should either:

  • Fix the data type at the source (preferred): modify the SQL query or view to cast both fields to the same type (e.g., CAST(CustomerID AS INT) in both tables) before Tableau joins them.
  • Use Tableau Prep to clean and standardize the join key before loading into Tableau Desktop.
  • In Tableau Desktop, create a calculated field that converts the string to an integer (e.g., INT([CustomerID])) and use that calculated field as the join key. However, this may impact performance and is not always recommended for large tables.

The analyst should verify the row count after the fix and ensure that the join returns the expected 1,200,000 rows. Additionally, they should check for any other data quality issues, such as nulls or whitespace, that could cause mismatches.

2. If the analyst cannot modify the source database, what alternative approach in Tableau can ensure all orders are included without losing data?

Read the worked answer

If source modifications are not possible, the analyst can use a left join from Orders to Customers instead of an inner join. A left join will include all rows from Orders, even if there is no matching CustomerID in Customers. However, this will result in null values for customer attributes for the 50,000 unmatched orders. To handle this, the analyst can:

  • Create a calculated field to flag unmatched orders (e.g., ISNULL([Customer Segment])).
  • Use a data blend or relationship with a calculated key that standardizes the join key (e.g., INT([CustomerID]) in both tables) if using relationships.
  • Alternatively, use Tableau Prep to create a clean extract where the join key is standardized, then publish that extract as a data source.

The key is to ensure that the join logic accounts for the type mismatch. The analyst should also validate the results by comparing totals before and after the join.