Union Your Data in Tableau

In this blogpsot we will understand how to union our data in Tableau. My earlier posts were about parameter actions and we learned how to achieve things using them. If you have yet not gone through them you can visit them here.
Union can be understood as a way to append data to your existing data. It involves addition of row to the existing data. An important thing to consider while you union your data is that , the data should come from the same connection. By same connection we mean that they should be of the same type. You can union multiple excel files with each other and multiple sql tables with each other , but what you cant do is union an excel file and a sql table.

If your data set supports the union feature you will see a New Union indicator on the left side of your data source sheet.

Here is the list of data-sources that are supported on Tableau Desktop to union your data:

Union in tableau can be done using two ways : Manual & Wildcard.
Lets try to understand union through some examples.

Wildcard


Lets say you have three excel files present in one folder and each of the excel files contains the sales for a specific month.

To union all of these connect any of the excel file to Tableau. Your data source tab will look as under:

Here I have connected the July excel file to tableau , to link it to the folder that contains the sales for the three months, Remove sheet 1 from the canvas area and from the left side , drag the New Union option on the canvas. Once you drag the new union option , a pop up window will open as under:

Go to the tab that says wildcard and beside the sheets option type in * 2019 and hit on apply. Once you click on apply you will be able to see all three of your excel files appended on below the other and alongwith the existing columns you will have two extra columns – Path and Sheets which will help you to distinguish between the three excel files. Here is a preview of the screen that comes up once you hit the apply button:

The popup window also has multiple options to include the parent folder as well as the sub folder. Give these options a try and let me know in case you feel any difficulty.

Manual

The next method to do a union in Tableau is by manually dragging the sheets on below the other. This is generally used when your data resides in one excel file but in different tabs as under:

Here we see that our sales for different months in three different tabs of the excel file . To union them connect your excel file to the data and then from the left side of the data source tab , drag the new union option in the canvas. Once the pop up window comes up , drag these sheets manually one beneath the other as shown below:

Once you hit on the apply button you will be able to see all the sheet stacked on below the other .

Hope you guys found this informative . Let me know in case if you are not able to follow any of the concepts described above.

Happy Learning!

Please follow and like us: