1. Unioning tables
Welcome. In this screencast, I will show you how to union multiple data files. First I’m going to open Tableau. This is the Data Source page. Using the Tableau icon on the top left, I can go between this page and my blank worksheets. Before we do anything, we need to connect data.
The superstore dataset is bundled up in a excel workbook containing multiple sheets, so I’ll click the”Microsoft Excel” option. There’s the file I want so I’ll click open.
Now we see it show up here as connection with all the sheets it contains listed down here. In this particular demo, we are interested in the orders sheets and we want to union them to get all the orders from 2016 to 2020 in one place.
So I’ll drag in 2016 first and here we get a nice preview of the sheet. It has a bunch of columns from Order ID, order date, customer info, location, to profit. All the other Orders sheets have these columns as well.
So what I’ll do now is right click on the table and select open.. you can also double click it. we can use Tableau’s drag and drop functionality to take the 2017 table and put it into the area labeled “Drag Table to Union”. And now we see that Orders 2016 is made of 2 tables now - we will change that name in a bit. I can double check that within the “Edit Union Option”... And we see the two tables here. I can remove the union by simply pressing the X.
It’s very important to drag the table into the designated union area. If you don’t, it will cause a join. If you do that by accident, no worries, you can simply remove it.
Going back to edit union, you can also drag the tables here. So I will do that for the years 2017 to 2020. I can do that one at a time. Or shift select multiple.
Now that we’ve stacked our data, we should rename this table since it’s no longer accurate. To do this, we first close the dialogue box. We can right click the table and select “Rename” to rename it Orders 2016-2020.
I can also edit the data source name here.
it’s best practice to verify the number of records in our newly unioned table. Let’s go to our worksheet!
Here we have our column and as expected the Tableau generated count field. As a reminder, this represents the number of rows. We can make it text... or a bar chart... to find out we have just shy of 12,000 rows. We can add fields like regions, to see where orders have come from in these past 4 years. Ok, it’s now your turn!
2. Let's practice!