Unions

A union is another way to combine your data. When you union two tables, you append the rows from one table to another. Since you are effectively stacking tables on top of each other, there is one important condition that must be satisfied – the data types of the columns that will be stacked need to be compatible. You should not stack a date column on top of a text column.

The following table includes a description of a union along with a Venn diagram visual to help you visualize how a union operates:

Union Description Venn diagram of Union
Union The result set of a union is all records from the first table appended to all records from the second table. 

 

To illustrate unions, we will append the Orders table to itself; this will yield a result set where every record is duplicated. Make sure the Global Superstore Orders 2016 connection is highlighted then click and drag the Orders table to the canvas on top of the Orders table rectangular button already in the canvas. Drop it on top:

You will see a plus symbol to the right of the Orders table icon and table icons peeking out underneath. This indicates that the union was successful:

If you right-click the Orders table icon, a submenu will appear. Click on Edit Union...:

The Specific (manual) menu allows you to see how many tables are in your union. You can also union tables by dragging tables on the canvas of the Specific (manual) menu:

A second option is for Tableau to automatically include tables in your join based on wildcard criteria that you set up. This is useful when you would like to append numerous tables that may have different date suffixes:

In Tableau, you cannot union tables from different databases (cross-database unions), but this may be changed in future updates. While you cannot union tables from different databases, you can union tables (sheets) from different Excel workbooksTableau has released a tool called Tableau Prep Builder that allows you to union data across multiple connections but that is beyond the scope of this chapter. For more information on Tableau Prep, visit the product page at https://www.tableau.com/products/prep.

Next, we move onto blends and how they differ from joins.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.55.151