Creating a Cross-Database Union in Tableau Desktop

Data

Creating a Cross-Database Union in Tableau Desktop

Data in the real world is a lot messier than we’d imagine it to be. More often than not, working with data will involve multiple sources. For example, you might want to combine two tables, like sales from subsequent quarters.

In Tableau Desktop, this is made simple with the Union operation, which allows us to append rows of one table onto another one. However, this operation does not allow combining data sources from different databases. (Tableau Prep offers a union function, but let’s assume that it is unavailable and your boss needs the job done right and quickly.)

The solution? A cross-database join. In a few simple steps, we can trick Tableau into creating an outer join to extend the table vertically:

Combine Data Sources from Different Databases

Here’s how we can get the joining result we’re looking for. First, create a full outer join of two tables from different databases based on equality condition, i.e. by using calculated fields where 1 equals 2:

Next, create combined fields by IFNULL() function:

This simple workaround allows Tableau Desktop to union tables across databases without an ETL tool. It’s a quick and dirty solution that comes with a cost of increased data structure complexity. But don’t be afraid of using it. Just be mindful not to add more data tables, thus causing maintenance and troubleshooting problems in the long run.

More About the Author

Han Zheng

Analytics Consultant
Creating a Cross-Database Union in Tableau Desktop Data in the real world is a lot messier than we’d imagine it to be. More often than not, working with data will involve multiple ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072