Tableau join with calculated field

I recently ran into a problem with a join: I had two tables with “customer class” IDs in them, but I needed the description – which was only available for the customer subclass. In a rush, I joined the tables on customer class and filtered the subclass descriptions to one description per customer class.

I ended up, of course, with a cross join, and my sales numbers exploded.

A developer I work with ambled over, and pointed out that the first of the subclass descriptions each started with two blanks (not apparent in Tableau), and those were the descriptions I wanted, so why didn’t I create a field with two blanks as a subclass in my primary table to join with subclass in the secondary? This would then pull in only the main descriptions I wanted.

Turns out, you can join on a calculated field!

The left table didn’t have a subclass, so I selected Edit Join Calculation.

I wrote the calculation directly in the dialog that opened.

And voila! A clean join. It’s a really useful trick to have in your back pocket – hope it helps someone else out there!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress.com.

Up ↑

Discover more from Datagami

Subscribe now to keep reading and get access to the full archive.

Continue reading