Learn everything about Analytics

Intermediate Tableau guide for data science and business intelligence professionals

Introduction

The greatest value of a picture is when it forces us to notice what we never expected to see. – John W. Tukey

Let’s assume that you have some data with you and you wish to garner some insights from it. Coding is not your forte and you don’t know how to get started.

Let me tell you this – you can make something as descriptive / insightful as the image below, with gestures as simple as drag and drop. And it doesn’t even require a single ounce of coding. Now that is the power of Tableau for you!

For all those reading this who have been acquainted with Tableau, can plot a few basic charts on it, and wish to learn more about its wide horizons, this article is meant for you.

As for those who have yet to be introduced to the beauty and simplicity of Tableau, quickly go through Tableau for Beginners first. Practice making a few simple visualisations and then rush back here!

In this article we are going to discuss a few core functionalities of Tableau which help in making really dynamic graphs. So let’s quickly get started!

 

Table of Contents

  1. Dealing with Different Data Sources
    1. Joins
    2. Data Blending
  2. Conditional Combination of Data
    1. Groups
    2. Sets
  3. Calculations and Level of Detail
  4. Parameter Control
  5. End Notes

 

1. Dealing with different data sources

1.1 Joins

Its not practical to store all data in a single table. In order to avoid anomalies related to updates, data is almost always distributed in multiple tables that have some relation with each other. Let’s understand the same with an example.

Consider the situation where a Superstore, on the verge of expansion, perceives that the number of Returned orders has been increasing by day. To ascertain the analysis and come up with the right action plan, they plotted the following chart to understand the products that were being returned :

As can be observed, Binders have the maximum number of items being returned. But judging by the color of the bars, Machines and Tables have the highest percent of return ( returned / bought ) :

This seems pretty similar to plotting just another chart, but the trick here was that it was created by using the combined data of two tables : Orders and Returns. This is known as a Join.

Let’s try making the same to get a better understanding :

  1. Go ahead and download the Sample Superstore Sales data from here. 
  2. Open Tableau and import the same :

The dataset is made up of 3 tables : Orders, People and Returns, and the ones that we are interested in at the moment are Orders and Returns.

  1. Drag Orders onto the empty area and use the Data Interpreter to get rid of the erroneous data.
  2. Drag Returns in the same area to get something like this :

For two tables to be joined, there has to be the presence of at least one common field. Here, Tableau automatically Inner Joined the two tables, based on the commonality of the column Order ID. By way of inner join, the combined data only consists of those rows that have the same Order ID in both the tables.

You can change the Join Type as well as the Joining Field in Tableau, but you need to ensure that it’s sensible.

Changing the Join type  (Default Inner to Right) :

Changing the Join field :

See how I tried to join the two tables based on Row ID of Orders and Order ID of Returns? Since the two are not compatible, we don’t see any records, and plus that red mark near the circles shows an error.

Let’s get back to working on the chart now :

  1. Drag Sub-Category of table Orders onto Rows and Number of Records of Returns onto Columns.
  2. Drag Row ID onto the Marks Section and convert its measure to Count instead of Sum. Now drag this onto the chart :
  3. Finally go to Show Me and choose the Bullet Graph to get the desired chart.

 

Here we have used Inner Join, but you can always choose between Inner, Right, Left and Full Outer based on your requirements.

 

1.2 Data Blending

Data blending is quite similar to Joins, with the difference being that Joining requires the data to be from the same data source. In the above example, we used different tables from the same Excel file. But Data Blending comes into the picture when you are working with different Data Sources. Let’s understand the same with an example.

The Superstore has another vertical in the form of a Coffeechain which is spread across as many states as the Superstore is. But they are considering shutting down some of the branches after observing the following plot :

As can be seen there are some branches that are doing equally well as the Superstore such as California and New York, while many are not, such as Iowa and New Mexico. Just like in Joins, here the trick is that both the datasets, dealing with the two verticals, were stored in different Data Sources, an Excel file and a TDE database.

Why not we plot the same as well to get a better understanding? We will begin by blending the Superstore data and the Sample – CoffeeChain database. You can find the data for the latter here as well:

  1. First import the Sample-Superstore.xls
  2. Go to the Worksheet, click on Data -> New Data Source and choose the downloaded CoffeeChain TDE file, to see both the datasets imported :
  3. Click on the States under the Superstore database and drag it onto Rows and drag Sales onto Columns.
  4. Click on the CoffeeChain database and drag Sales onto Columns as well to get :

Here you must have observed a few things; let’s take them up one by one :

  1. To the top-left of the screen, the Superstore database now has a blue mark on it – this indicates the Primary Source.
  2. The CoffeeChain data has an orange mark on it – this indicates the Secondary Source.
  3. There is an orange chain link next to State under CoffeeChain – This indicates the Blended Field, meaning that this field is common in both the datasets.
  4. There are ‘>29 null’ values in the chart. This is because there are not as many states in the CoffeeChain dataset (Secondary Source) as there are in the Superstore dataset (Primary Source).

Let’s rectify these null values by interchanging Steps 3 and 4 :

  1. Click on the States under the CoffeeChain database and drag it onto Rows and drag Sales onto Columns.
  2. Click on the Superstore database and drag Sales onto Columns as well to get :
  3. Change the chart of each graph from the Marks section to Area chart :
  4. Right click on the second chart and choose Dual Axis to merge the two graphs into one :
  5. Now all that is left is changing the color scheme and you just finished blending!

 

2. Conditional Combination of Data

Now that your data is all ready, blended or joined, let’s start making some interesting dashboards. From here on out, we will be using only the Superstore data: Orders + Returns (Left-Joined).

2.1 Groups

Let’s start off by considering the example of a Survey analysis. In a survey of Food Consumption, under the section of Food Preferences, instead of ‘Low Fat’, you may have ‘LF’, or instead of ‘Regular’, you may have ‘reg’.

In such cases, during data visualisation, you face issues like the following:

As you can see, due to different nomenclatures, this visualisation is not ideal. So, one possible solution to this is Grouping where you can place ‘LF and ‘Low Fat in one group, and ‘reg‘ and ‘Regular‘ in another : 

Let’s understand this a bit better with the help of the following Dashboard :

The above is the Returns Analysis across Categories and their Sub Categories. Although, it cannot be seen, in the bar graph, Copiers have the maximum Return percentage, followed by Furnishings :

As far as the Line Chart goes, it seems that the Sales Team had been right all along. The Returns were in fact increasing quite rapidly, but luckily from what we can see, the rise is slowly receding.

From the pie charts, you can clearly analyse the Returns of each Category. As can be observed, Technology suffered the maximum number of Returns.

Another analysis, which I am going to leave for you to make, could be the Return distribution across the various States. Once you finish learning how the above graphs were made, you can easily make this too. So, let’s get started :

  1. We are going to begin with the following graph, and do take note that the dataset is a Left Join of Orders and Returns :

  1. In another sheet, make this graph :

  1. You see the Dimension of Returned under Returns? This is what we are going to use to make our groups. Right click on this Dimension :
  2. Go to Create – > Group. Since we are going to make groups of products that were returned or not, click on Null -> Group, and change the name :

  1. Do the same for Yes, and get to the final configuration :

  1. Click on Apply -> OK, after which you will see a group by the name of ReturnedOrNot under Dimensions.
  2. Drag this new Dimension over the Color in the Marks Pane to get the following view :

This step automatically segregated the Sales of each Sub Category based on whether the Orders had the Null or Yes value under Returns or not.

The remaining steps are merely customisation. Let’s do those as well :

  1. Drag Sales onto Label in the Marks Pane
  2. Right click on the Sales pill -> Quick Table Calculation -> Percent of Total
  3. Right click on the Sales pill again -> Compute Using -> Table (across)

Also, in the Legends, you will most likely see ‘In/Out’ as the aliases. You can change this as per your requirements, by right clicking on the In/Out blue pill in the Marks Pane, and choosing Edit Alias.

Let’s shift to the pie chart that we had made. We are going to apply the same ReturnedOrNot group to this as well. First create two duplicates of this sheet, and work on one of them :

  1. Drag the group onto the chart, to get something like this :

  1. Right click on Returned, to get :

  1. Choose Keep Only, so that you just see the Returned graph. This gives you the Total loss from Returns. All that is remaining is labelling with the Sales value. 
  2. Now go to the second duplicate of the sheet, repeat the first 2 steps, and instead of keeping the Returned chart, we are going to keep the Not Returned chart. This will give you the sales of the Remaining / Retained Orders.

Its equally easy making the Line Chart :

  1. Drag Order Date to Columns and Sales to Rows to get a Line Chart
  2. On top of this chart, drag the ReturnedOrNot Dimension, but just like you had before, exclude the Not Returned Line, right clicking on it and choosing Exclude.

All that is left now, is combining the above Worksheets into one Dashboard. Why don’t you try making the chart for State wise Returns distribution as well?

 

2.2 Sets

After taking note of the Returns analysis, your organisation decided that the increase in Returns was not that alarming, and that it should not be constituted as a reason for non – expansion.

But the Superstore is only going to expand in those States where the Sales and Profit both have crossed a certain margin, for example, 40,000 and 10,000 respectively :

So, Sets, as are created above, are really similar to groups. In Set, you group data that fulfils a particular set condition. Another interpretation could be: Groups help you attain a higher level hierarchy, as we had seen in the previous example, whereas Sets help you attain a lower level granularity.

Let’s understand this better by creating the above Dashboard :

  1. We are going to start off with a simple Map Chart. Since we are going to map our Sales and Profits onto this graph, right click on States and choose Create -> Set.

  1. Fill in the fields with the following demo information :

  1. Right click on States once again, and this time fill information for the Profit Margin :

  1. Now we are going to join the two sets to obtain our desired configuration. So right-click on SalesAbove40k set -> Create Combined Set :

  1. Fill in the fields with the following configuration :

This step joins the above two conditions for Sales and Profit, to get the requisite combined computation. To view the results :

  1. Drag this new Set on top of the Map Chart, and convert it into a Filled Map instead of the Symbol Map :

You can always customise the above chart by changing the colour, adding labels etc.

The line chart is as easy to make as the one we had made previously for Trend of Return. Here we have excluded the States that belong to the No Expansion group, like we had excluded the Not Returned there.

 

3. Calculated Field 

The Superstore dataset is pretty comprehensive. It offers quite a lot of information and field sets. But like all data, there is always the possibility of extracting more features. Calculated Fields help you do exactly that while also allowing you to carry out both simple and complex calculations on the data.

So what is a Calculated Field?
To put it in simple words, it’s a formula that you apply to your data, where the various Measures act as the variables.

How to create one?
Just simply go to Analysis, click on Create Calculated Field and something like this will pop up :

Here is where you write your formulas, and as you can see, Tableau provides you with the various syntaxes too, so that you never feel lost! You can also apply ‘If-Else’ conditions, ‘Case’ conditions (as we shall see next) and of course the usual mathematical computations too, which we will explore now.

So what Calculation to start with? Let’s begin with something simple, that is, Average Sales associated with the Orders. The most apt formula for the same would be Total Sales / Total Number of Orders. To convert this formula in Tableau terms, Total Sales implies the SUM of Sales, whereas Total Number of Orders means their COUNT.

Let’s get to the application then :

  1. In the Calculation Box, make the following changes :

  1. To see the cumulative SalesRevenue (Calculated Field), drag Measure Names from Dimensions to the empty area to see the above computed result :

So what you have basically accomplished with the Calculated Field is create a Measure of your own, which you can use just like Sales and Profits.

Obviously this was just a gist of what Calculated Fields can do. They can be used for various complex calculations as well, and the glimpse of one such instance can be seen in the following section.

 

4. Parameter Control

Filters such as the following are a great way of interacting with the visualisations on Tableau :

Just like filters are measures through which you can look at various aspects of your data, a Parameter is another great feature. It can be used in place of Filters, and can exhibit its own dynamic property too.

So what are Parameters? These act as variables of an equation, which you can change to get different results each time.

Let’s try and understand this with the help of an example. So far we have been making separate graphs for separate Measures. Whenever we had to analyse Sales, Profits, Quantity or Discount of the various Categories of Products, we had to make different charts, everything being the same BUT the Measures.

With the power of Parameter Control, there is actually a pretty easy way of going about this, without the repetitions.

Consider this for Sales :

And the following for Profit :

Just with a simple click on the MeasureValue list, you are getting cumulative results across various Dimensions. Here, the MeasureValue is our Parameter, since we are able to change its value.

Let’s get to making one of our own now. Parameters rely heavily on Calculated Fields, so you are going to get a nice chance to practice what you learned above:

  1. We are going to start off with a blank screen this time.
  2. Click on the downward arrow near Dimensions, and choose Create Parameter :

  1.  Since we are going to interchange the Measure Values between Sales, Profits, Quantity and Discount, fill in the fields shown below and click OK :

  1. Right click on the newly generated Parameter, and choose Show Parameter Control:

Do not expect the drop down list to start magically creating graphs on its own. There are still some computations to be done.

So far we have only allocated the names to the Parameter, but not the Values that they are supposed to take up. So for this purpose, we are going to create a Calculated Field.

  1. Go to Analysis -> Create Calculated Field, and fill it with the following self explanatory details  :

  1. You will find the newly created field under Measures. So first drag Order Date to Columns and then NameOfMeasure to Rows :

There you go! Go ahead and try changing the MeasureValues now.

Now onto the chart we have created in the Dashboard. To see the lines for the individual Categories, simply drag that Dimension on top of the chart :

For creating other charts, do as you normally would, but instead of dragging the individual Measures onto the Rows / Columns, drag the NameOfMeasure parameter instead.

 

5. End Note

That brings us to the end of this article. But don’t worry, I will be back again with another article on Tableau!

Meanwhile, I think it’s customary to give you a Dashboard to make :

You may face a tad bit of difficulty in the beginning, but if you truly apply yourself, you are bound to get it. And of course if there are ever any doubts, or if you wish for me to cover any concept in the next article, do leave them as comments.

All the best to you Data Explorers! 

LearnEngageCompete & Get Hired

 

You can also read this article on Analytics Vidhya's Android APP Get it on Google Play
This article is quite old and you might not get a prompt response from the author. We request you to post this comment on Analytics Vidhya's Discussion portal to get your queries resolved

17 Comments

  • Matt Sandy says:

    This is the most in depth article I have seen about Tableau. I mostly use it for a few merged charts in one Dashboard, but this is so much more involved. Great work.

    • Pavleen Kaur says:

      I am glad you appreciated the article Matt.
      Tableau can infact be used in a variety of ways to accumulate detailed and clear insights. Do try them out.

  • nikhil says:

    Great work pavleen this is what i was looking after your first article on tableau.
    Will help alot in cracking interviews.
    Will you post the advance level too after this?

  • Hita says:

    Hello Pavleen, great one! Request you to re-upload the coffee chain data as an excel or csv, the .tde file read is not supported by the tableau public edition that I am working off.

    thanks

  • JOSE LUIS CRUZ says:

    I appreciate a lot this article, because it is explained very clear, and it is very useful to practice with examples and explore possibilities. I would like to ask if it could be developed similar articles, but for special interest, like the use of statistical tools, and the use of statistical formulas with calculated field.
    In particular, I would like advise in calculating the product of 3 last values in a time serie in all the table, and then to calculate the moving average of that product for periods of 3 months.
    Best regards

    • Pavleen Kaur says:

      Hey Jose,
      Glad you liked it. I am infact working on another detailed article which will cover exactly what you mentioned.
      Thank You.

  • Manoj Prabhakar says:

    Hi can you please attach the workbook

  • balram sidh says:

    You wrote an awesome article, Pavleen! Thanks a ton!

  • Akshay says:

    Very nice article, i have a doubt in the creating the dashboard , can you please help me out?

  • Parul says:

    Another great article on Tableau. It has everything to get seriously involved with Tableau.Great Job. Most of the articles available online regarding Tableau only deal with the basic stuff. You have so beautifully curated a guide for tableau learners giving them much more than just the basic…

  • Gopika Bhardwaj says:

    Very Helpful. The way the content has been curated with simple yet effective terms is indeed impressive. Looking forward to implementing! Thank you.

  • Avik Aggarwal says:

    Hi Pavleen,
    Great article. Got to know a lot working on these two articles, will be starting with Advanced version soo.
    Could you please have a look at my solution for this article’s problem. Thanks
    Link: https://public.tableau.com/profile/avik.aggarwal#!/vizhome/SuperStoreIntermediate/CustomerAnalysisDashboard

Join 150000+ Data Scientists in our Community

Receive awesome tips, guides, infographics and become expert at:




 P.S. We only publish awesome content. We will never share your information with anyone.

Subscribe!
Join 150000+ Data Scientists in our Community

Receive awesome tips, guides, infographics and become expert at:




 P.S. We only publish awesome content. We will never share your information with anyone.

Subscribe!