Felicia Styer
Are you struggling to combine data from different data sources? This video demonstrates how to combine tables in Tableau using Relationships and the Logical Layer.
Hi, I am Felicia Styer with Playfair Data, and in this video I’m going to be showing you how to use Tableau’s logical layer to create relationships.
Now, I’ve already set up the orders table from Tableau Superstore in this workbook, and I’m going to be adding relationships to the people and returns tables. Both of these tables exist inside the same Excel workbook, so all I need to do is drag them from our connections pane over into the logical layer canvas.
So now when I drop people here, Tableau automatically creates the relationship between the two tables, and it has detected that both tables have a field called region and has already set that up as our relationship condition. So there’s no need to modify this relationship, it’s ready to go.
Now I’m going to add returns in the same way, and this time I have two options. I can either connect it to orders or I can connect it to people. Now there’s actually no relationship between the people and returns table. So now that I’ve dropped it in the wrong place, all I need to do is pick it up and drag it to the right spot. Once again, Tableau has detected that these two tables share a field and has set up our relationship for us.
Let’s add a slightly more complicated scenario. I’ve created a table called Superstore Targets that I’m going to add from another file. Now this file is an Excel file, but I could pull from any other data source type with a logical layer. So this could be a text file, it could be a database connection, I’m not limited to Excel. I’m going to pull in this Superstore Targets file, and then we’re going to bring in the targets table from this file. This table is also related to orders, I’m gonna drop it right here, and let’s look at what fields are available to us in the Targets table.
From here, I need to create relationships based on our region, segment, category, and year fields. Let’s start setting those up by clicking on the noodle between orders and targets. And I’ll start with category and then I can add another condition here and let’s add region. This time I’m going to search for it instead of scrolling. I am going to do this a third time for Segment. And then finally, we need to set up a relationship for year.
Now we have a year field in our Targets data source, but we don’t have a field called year over in orders. We need to relate it to our order date field. Now, when I set up a direct match between the two, we have an error because order date is stored as a date, while year is stored as a number. Instead of using the order date field directly, I need to use a calculation. So I’ll go in here and click on edit calculation. And all I need to do is add the year function to order date to isolate the year date part. This will result in two numbers, clearing up our data type error. And now we’re ready to go. If you’d like to learn anything else about relationships in Tableau’s logical layer, please check out my written tutorial series about bringing tables together. This has been Felicia Styer with Playfair Data.