Get startedGet started for free

Joining tables

1. Joining tables

Now it’s time to learn how to do Joins on Tableau. Let’s open up the Orders 2016-2020 table we made by unioning the 5 orders tables. I’m going to bring Returns now into the canvas. As seen in the previous demo, you can drag the table outside of the designated union area to create a join. Note that we dragged it within the dialogue box of Orders 2016-2020. If we do it outside of the dialogue box, it creates a Relationship - which we’ll cover soon! I’ll remove the relationship for now and go back to where I was. Before we get into the details of this join, let’s understand what we want from the join. We can preview the Returns table here. It is very simple, it contains the ids of all the orders that have been returned from 2016 to 2020. And there’s a “returned” column with a value of yes for all the rows in this table. Note this table does not contain IDs of orders that have not been returned. In our Orders 2016-2020 table, we want to add a column indicating whether an order has been returned or not. We can accomplish this by joining the Orders 2016-2020 table with the Returns table. But first we need to make sure that we select the right type of join. We can do that by clicking the join icon and here we have the four types of joins we’ve discussed. By default Tableau gives us an inner join. This isn’t good because it only returns matched rows, so orders that have not been returned won’t show up since their IDs aren’t in the returns table. This means we want the left join to ensure we don’t lose any orders in the Orders 2016-2020 table. This is where we define what tableau should join on. Tableau has already guessed correctly that we want to join on Order ID, in other words Order ID is our “key”. If you needed to change that, you could use the dropdown. Let’s go to our sheet and see what we have. If we drag the count field, we still have 11,979 rows which is what we expected. Let’s try out our new returned field by dragging Returned to color in the marks card. We can see the proportion of orders that have been returned. We can add the date field to column to further enrich our viz as well as select the “show mark labels” option for better readability. If we look at the legend, we see that blue corresponds to Null. This means the order was not returned because the order id was not found in the Returns table, thus giving it a null value in the “Returned” column. Although we may understand this, we should change this to be clearer to any viewers of our viz. I can right click on Null within the legend and select edit alias. here I’ll give it the name No. There we go! Before you get to some exercises, remember we can always return to the data source tab to edit our table!

2. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.