
Last chance! 50% off DataCamp Premium
Sale ends in
Buy Now
Tableau Software is a software company headquartered in Seattle, Washington that produces interactive data visualization products focused on business intelligence. Tableau was established at Stanford University’s Department of Computer Science between 1997 and 2002(Wikipedia)
The main products offered by tableau are:

Tableau Desktop, Tableau Public, and Tableau Online, all offer Data Visual Creation and choice depends upon the type of work

In this tutorial, we will be working with Tableau Desktop. The link for the source of reference is here.
Depending upon the choice of product, download the software on to the computer. After accepting the license agreement, you can verify the installation by clicking the Tableau Icon. If the following screen appears, you are good to go.

In this section, we will learn some basic operations in Tableau to get accustomed to its interface.
The Tableau workspace is a collection of worksheets, menu bar, toolbar, marks card, shelves and a lot of other elements about which we will learn in sections to come. Sheets can be worksheets, dashboards, or stories. The image below highlights the major components of the workspace. However, more familiarity will be achieved once we work with actual data.

To begin working with Tableau, we need to connect Tableau to the data source. Tableau is compatible with a lot of data sources. The data sources supported by Tableau appear on the left side of the opening screen. Some commonly used data sources are excel, text file, relational database or even on a server. One can also connect to a cloud database source such as Google Analytics, Amazon Redshift, etc.
The launch screen of Tableau Desktop shows the available data sources that one can connect too. It is also dependent on the version of Tableau since the paid version offers more possibilities. On the left side of the screen, there is a Connect pane which highlights the available sources. File types are listed first, followed by common server types, or the servers that have been recently connected. You can open previously created workbooks Under Open tab. Tableau Desktop also provides some sample workbooks under Sample Workbooks.
Hands On
We shall be working with a sample data set names Superstore dataset, that comes pre-loaded with Tableau. However, we will be downloading the file from here so that we can get an idea of connecting to an Excel data source. The data is that of a superstore. It contains information about products, sales, profits, etc. Our aim as Data Analysts is to analyze the data and find critical areas of improvement within this fictitious company.
StepsImport the Data into tableau workspace from the computer.
Under the Sheets Tab, three sheets will become visible namely Orders, People, and Returns. However, we will focus only on Orders data. Double click on Orders Sheet, and it opens up just like a spreadsheet.
We observe the first three rows of data looks a bit different and is not in the desired format. Here we make use of Data Interpreter, also present under Sheets Tab. By clicking on it, we get a nicely formatted sheet.
Hands On
We will start by generating a simple chart. In this section, we will get to know our data and will begin to ask questions about the data to gain insights. There are some important terms that we will encounter in this section.
Dimension
Measures
Aggregation
Dimensions are qualitative data, such as a name or date. By default, Tableau automatically classifies data that contains qualitative or categorical information as a dimension, for example, any field with text or date values. These fields generally appear as column headers for rows of data, such as Customer Name or Order Date, and also define the level of granularity that shows in the view.
Measures are quantitative numerical data. By default, Tableau treats any field containing this kind of data as a measure, for example, sales transactions or profit. Data that is classified as a measure can be aggregated based on a given dimension, for example, total sales (Measure) by region (Dimension).
Aggregation is the row-level data rolled up to a higher category, such as the sum of sales or total profit.
Tableau automatically sorts the fields in Measures and Dimensions. However, for any anomaly, one can change it manually too.
StepsGo to the worksheet. Click on the tab Sheet 1 at the bottom left of the tableau workspace.

Once, you are in the worksheet, from Dimensions under the Data pane, drag the Order Date to the Column shelf.
On dragging the Order Date to the columns shelf, a column for each year of Orders is created in the dataset. An 'Abc' indicator is visible under each column which implies that text or numerical or text data can be dragged here. On the other hand, if we pulled Sales here, a cross-tab would be created which would show the total Sales for each year.
Similarly, from the Measures tab, drag the Sales field onto the Rows shelf.
Tableau populates a chart with sales aggregated as a sum. Total aggregated sales for each year by order date is displayed. Tableau always populates a line chart for a view that includes time-field which in this example is Order Date.
Hands On
Let us delve deeper and try to find out more insights regarding which products drive more sales. Let's start by adding the product categories to look at sales totals in a different way.
StepsCategory is present under the Dimensions pane. Drag it to the columns shelf and place it next to YEAR(Order Date). The Category should be placed to the right of Year. In doing so, the view immediately changes to a bar chart type from a line. The chart shows the overall Sales for every Product by year.
Learn More
To view information about each data point (that is, mark) in the view, hover over one of the bars to reveal a tooltip. The tooltip displays total sales for that category. Here is the tooltip for the Office Supplies category for 2016:

To add labels to the view, click Show Mark Labels on the toolbar.

The bar chart can be displayed horizontally instead of vertically too. Click Swap on the toolbar for the same.

2. The view above nicely shows sales by category, i.e., furniture, office supplies, and technology. We can also infer that furniture sales are growing faster than sales of office supplies except for 2016. Hence it will be wise to focus sales efforts on furniture instead of office supplies. But furniture is a vast category and consists of many different items. How can we identify which furniture item is contributing towards maximum sales?
To help us answer that question, we decide to look at products by Sub-category to see which items are the big sellers. Let's say for the Furniture category; we want to look at details about only bookcases, chairs, furnishings, and tables. We will Double-click or drag the Sub-Category dimension to the Columns shelf.
The sub-category is another discrete field. It further dissects the Category and displays a bar for every sub-category broken down by category and year. However, it is a humongous amount of data to make sense of visually. In the next section, we will learn about filters, color and other ways to make the view more comprehensible.
Hands On
In this section, we will try to focus on specific results. Filters and colors are ways to add more focus to the details that interest us.
Filters can be used to include or exclude values in the view. Here we try to add two simple filters to the worksheet to make it easier to look at product sales by sub-category for a specific year.
StepsIn the Data pane, under Dimensions, right-click Order Date and select Show Filter.Repeat for Sub->category field also.

Filters are the type of cards and can be moved around on the worksheet by simple drag and drop
Colors can be helpful in the visual identification of a pattern.
StepsIn the Data pane, under Measures, drag Profit to Color on the Marks card.

It can be seen that Bookcases, Tables and even machine contribute to negative profit, i.e., loss. A powerful insight.
Hands On
Let's take a closer look at the filters to find out more about the unprofitable products.
StepsSub-Category filter card, uncheck all boxes except Bookcases, Tables, and Machines. This brings to light an interesting fact. While in some years, Bookcases and Machines were actually profitable. However, in 2016, Machines became unprofitable.All in the Sub-Category filter card to show all the subcategories again.Region to the Rows shelf and place it to the left of the Sum(Sales) tab. We notice that machines in the South are reporting a higher negative profit overall than in your other regions.Sheet 1 and type Sales by Product and Region.Sales by Product and Region sheet and select Duplicate and rename the duplicated sheet to Sales-South.Region to the Filters shelf to add it as a filter in the view.OK. Now we can focus on sales and profit in the South. We find that machine sales had a negative profit in 2014 and again in 2016. We will investigate this in the next sectionFile > Save As. Let us name our workbook as Regional Sales and Profits.Hands On
StepsState and Country under Data pane to Detail on the Marks card. We obtain the map view.Region to the Filters shelf, and then filter down to South only. The map view now zooms in to the South region only, and a mark represents each state.Sales measure to the Color tab on the Marks card. We obtain a filled map with the colors showing the range of sales in each state.Color on the Marks card and selecting Edit Colors. We can experiment with the available palettes.Profit now since Profit is a better indicator than Sales alone.Profit to Color on the Marks card. We now see that Tennessee, North Carolina, and Florida have negative profit, even though it appeared they were doing good in Sales. Rename the sheet as Profit MapHands On
StepsDuplicate the Profit Map worksheet and name it Negative Profit Bar Chart.
Click Show Me on the Negative Profit Bar Chart worksheet. Show Me presents the number of ways in which a graph can be plotted between items mentioned in the worksheet. From Show Me select the horizontal bar option and the view updates to horizontal from vertical bars instantly.
We can select more than one bar at a time by simply clicking and dragging the cursor over them. We want to focus only on the three states, i.e., Tennessee, North Carolina, and Florida. Hence, we will only select the bars pertaining to them.
Learn More
Creating Hierarchies
Hierarchies come in handy when we want to group similar fields so that we can quickly drill down between levels in the viz.

On the Rows Shelf, click the plus-shaped icon on the State Field to drill-down to the City level.
N-Filter to filter and reveal the weakest performers. For that, drag City from the Data pane to the Filters shelf. Click By field and then Click the Top drop-down and select Bottom to reveal the weakest performers. Type 5 in the text box to show the bottom 5 performers in the data set.We now see that Jacksonville and Miami, Florida; Burlington, North Carolina; and Knoxville and Memphis, Tennessee are the poorest performing cities by profit. There is one other mark in the view—Jacksonville, North Carolina—that doesn't belong here since it has profitable sales. This means there is an issue in the filter we applied. We will take the help of Tableau Order of Operations.
On the Filters shelf, right-click the Inclusions (Country, State) set and select Add to Context. We find that now Concord(North Carolina) appears in view while Miami(Florida) have disappeared. This makes sense now.
But Jacksonville (North Carolina) is still present which is incorrect. On the Rows shelf, click the plus-shaped icon on City tab to drill down to the Postal Code level. Right-click the postal code for Jacksonville, NC, 28540, and then select Exclude to exclude Jacksonville manually.
Drag Postal Code of the Rows shelf. This is the final view.

Hands On
StepsSub-Category to the Rows to further drill down.Profit to Color on the Marks card. This enables us to spot products with negative profit quickly.Order Date and select Show Filter. It seems that Machines, tables, and binders are performing poorly. So what should we do? One solution would be to stop the sale of these products in Jacksonville, Concord, Burlington, Knoxville, and Memphis? Let's verify if our decision is right.Profit Map sheet tab.Sub-Category field to select the Show Filter option.Profit from under Measures onto the Label Marks card.Order Date and select Show Filter. From the filter let us clear off the items which we think are contributing to negative profit. So, uncheck the boxes in front of Binders, Machines, and Tables respectively. Now we are only left with the profit-making entities. This shows that the entities like Binders, machines, and tables were actually causing losses in some areas and we were right in our findings.Hands OnA dashboard is a collection of several views, enabling one to compare a variety of data simultaneously.
StepsNew dashboard button.Sales in the South to the empty dashboardProfit Map to the dashboard, and drop it on top of the Sales in the South view. Both views can be seen at once. To be able to present data in a manner so that others can understand it we can arrange the dashboard to our liking.Sales South worksheet in the dashboard view, click under the Region and clear off the Show Header. Repeat the same process for all the other headers. This helps to emphasize only what is needed and hides away the not so important information.Profit Map, Hide the Title as well and perform the same steps for the Sales South map.Sub-Category filter card and Year of Order Date have been repeated on the right-side. Let us get rid of the extra by simply crossing them out. Finally, click on the Year of Order Date. A drop-down arrow appears and select the option of Single Value (Slider). Now let the magic unfold. Experiment by choosing different years on the slider and the Sales also vary accordingly.SUM(Profit) filter to the bottom of the dashboard below Sales in South for a better view.Hands On
StepsProfit Map. On clicking the map, a Use as filter icon appears in the upper right. Click on it. If we select any map, Sales corresponding to that state will be highlighted in the Sales-South map.Year of Order Date, click on the drop-down option and go to Apply to Worksheets > Selected Worksheets. A dialog box opens up. Select the All option followed by OK. What does this option do? It applies filters to all the worksheets having the same data source.Sales South map to view products that are being sold in North Carolina only. We can then easily explore the profits yearly.Regional Sales and Profit.Hands On
Thus, selling machines in the North Carolina did not bring any profits to the company.
A dashboard is a cool feature, but tableau also offers us to showcase our results in presentation mode in the form of stories about which we will discuss in this section.
StepsNew story button.Sales in the South worksheet (created earlier) onto the view.Sales and profit by year.Duplicate to duplicate the first caption, or you may even create a new one.Sub-Category, filter select only Machines. This helps to gauge sales and profit of machines by year.Machine sales and profit by year.Hands On
StepsBlank. Drag the already created dashboard Regional Sales and Profit onto the canvas.Low performing items in the South.Duplicate to create another story point with the Regional Profit dashboard. Select North Carolina on the bar chart since we are interested in showing more about it.Profit in NC : 2013-2016.Profit in NC : 2014 and then click on the Duplicate tab. Repeat the same step for all the remaining years.story unfold.Hands On
Now we have an idea about, what products were introduced to the North Carolina market when, and how they performed. Not only have we identified a way to address negative profit, but have also successfully managed to back it with data. This is the advantage of Story in Tableau.
Apart from the various visualization advantages that Tableau offers, it also has an amazing out of the box connection capabilities. Tableau can easily integrate with languages like Python and R and even with DBMS like SQL. This offers increased advantages regarding functionalities and comes in handy for Data Scientists who are used to working in Python or R. They can directly import the R and Python scripts in Tableau and take advantage of its visualizations which are far more superior than that of these languages. Also, the visualization capabilities of tableau are easy to use and very intuitive, thereby saving a lot of time for the Data Scientists.
In this section, we will see how we can connect Tableau with these external sources and the advantages of these connections.
R is a popular statistical language used to perform sophisticated predictive analytics, such as linear and nonlinear modeling, statistical tests, time-series analysis, classification, clustering, etc.(Tableau 8.1 and R) Using Tableau in conjunction with R has the following advantages:
R functions and models can be used in Tableau by creating new calculated fields that dynamically invoke the R engine and pass values to R. These results are then returned back to Tableau to be used for visualization purpose.
Rserve.You will need to download and install Rserve package for Tableau to connect and utilize the R script functions. In the R console, enter the following commands:
install.packages(“Rserve”)
library(Rserve)
Rserve() / Rserve(args = ‘ — no-save’)
After Rserve is successfully installed, open Tableau Desktop and follow the below mentioned steps.
Go to the Help > Settings and Preferences and select Manage External Service Connection.

Enter the server name as “Localhost” (or “127.0.0.1”) and a port of “6311”.
Click on the “Test Connection” button. You should see a successful message prompt. Click OK to close.

Upon successfully accomplishing the above steps, we will be able to create new calculated fields in Tableau Desktop that utilize the SCRIPT_* functions to make R functional calls.
Let’s get to work and see how we can use tableau capabilities with R.We will utilize the inbuilt Sample Superstore dataset to calculate Profit both by using R script and by Tableau ‘s drag and Drop feature. We will then compare both the results.
StepsWe will now create a calculated field called Expected Profit.
Four functions are available for use with R, and they all begin with the word script. The functions are:
linear regression in Tableau.Open up the calculated field and insert the following script.
SCRIPT_REAL("fit <- lm(.arg1 ~ .arg2 + .arg3 + .arg4)
fit$fitted
",
SUM([Profit]), AVG([Sales]), AVG([Quantity]), AVG([Discount]))
The script above pertains to the linear regression model in R. This model will have one dependent variable(arg1) and three independent variables(arg2, arg3, arg4). These arguments are just placeholders, and when the script gets passed back to R, the arguments will be replaced with the tableau columns that they correspond too. 5. Input the tableau fields that correspond to each of the variables. The dependent variable here is profit, so we’ll put SUM(Profit) first since that corresponds to argument 1. Similarly, we will use the average unit price, average order quantity and average discount for the other three arguments respectively.
These inputs will now all be pulled into the model for determining expected profit levels. We are now ready to use this calculation within Tableau visualizations. Drag category over onto the rows and then Profit onto columns. Now drag Expected Profit over onto the columns.
We can now analyze the model to see how the Expected profit calculated in R compares to the actual profits. We can continue to analyze this further by pulling customer segments over onto the colors, and now we’ve created a stacked bar chart can also utilize ordered dates to break out the data by years or by quarters.
Hands On
One might wonder all the above calculations could have been done in Tableau without using R. So, why should we go through the process of downloading and configuring Rserve in Tableau and write scripts? R is a potent language because of its power to forecast, utilizing widely-used libraries that contain well-known algorithms easily. Imagine how nice it would be to make predictions for our business in Tableau, by calling a simple R script and then being able to incorporate it into Tableau's visualizations.
Python is a widely used general-purpose programming language. Python provides a large number of libraries to perform statistical analysis, predictive modeling or machine learning. Connecting Tableau with Python is one of the best approaches for predictive analytics. Tabpy is a package developed to do the same. To enable Tableau to harness the power of Python, it can be connected to the TabPy server to execute Python code on the fly and display results in the form of visualizations.
When we use TabPy with Tableau, we can define calculated fields in Python, thereby leveraging the power of a large number of machine-learning libraries right from our visualizations.
Download and Install Tabpy.
Running a Python code within a Tableau workbook requires a Python server to execute it. The TabPy framework is what gets the job done. Download TabPy from Github at the following link. Alternatively, you can follow the steps below:
Then cd to the directory containing the downloaded tabpy server and run.
The next step is to connect Tableau with TabPy. This can be done by going to Help > Settings and Performance > Manage External Service Connection:

Test the connection. If all goes smoothly, you should be greeted with a “successfully connected” prompt.
The Python integration in Tableau is a very useful feature. Take for instance the problem of Sentiment Analysis. It is a common problem in the Machine Learning community and can be accomplished by various machine learning Algorithms. However, by using a combination of tableau and Python, the same can be achieved in a few lines of Python code. The results can then be visualized in Tableau for further insights. Let us see this with an example(Leverage the power of Python in Tableau with TabPy)
Sentiment Analysis with Tabpy
We will be using the mobile reviews dataset which can be downloaded from here.
Steps:Tabpy, it can invoke the Python engine through calculated fields.We will now create a calculated field called Sentiment as follows: `
SCRIPT_REAL("from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
vs = []
analyzer = SentimentIntensityAnalyzer()
for i in range(0,len(_arg1)):
a = analyzer.polarity_scores(_arg1[i])['compound']
vs.append(a)
return vs",ATTR([Reviews]))`
We are using the VADER sentiment analysis tool here. It is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media. To use this tool, you will need to install it first. Please read more at their github page.
Now, drag Reviews onto rows and Sentiment onto Text and Color Marks card and see the magic happening. We get the sentiment analysis of the review done without any hassle. Also, it gets super easy to visualize the results too. The positive reviews are in increasing order of green while the negative ones are in red.

The above example clearly shows the power brought about by Tableau's integration with Python. By having the Sentiment scores at our disposal, we can work with it to dig deeper into the details. For instance, As a business owner, I can filter the negative reviews and contemplate on the reasons for the same. I can also filter on the positive reviews to get an idea about the products which makes the consumers happy.
There is a hidden value in our Microsoft SQL Server data which lies buried under the standard reports and complex business intelligence tools. Tableau delivers insight everywhere by equipping anyone to do a sophisticated visual analysis of SQL Server data. We can connect Tableau to SQL Server live for tuned, platform-specific queries, or directly bring data into Tableau’s analytical engine to take the burden off the database.
Tableau provides an optimized, live connector to SQL Server so that we can create charts, reports, and dashboards while working directly with our data. As we dig into our analysis, Tableau recognizes any schema used in SQL Server, so we don’t have to manipulate our data.
Let us walk through an example depicting how to connect SQL server database to Tableau Desktop and then use it to create visualizations.
Steps:Hands On:
This is how we can easily connect SQL Server to Tableau and extract the data directly into it. Tableau enables the users to toggle connections with a click to apply in-memory queries to a larger dataset.
To save a Tableau workbook locally, Select File > Save. Specify the workbook file name in the Save As dialog box. Tableau by default saves the file with the .twb extension.
With Tableau Public all the views and data is made public and anybody on the internet has access to it. Select Server > Tableau Public > Save to Tableau Public and enter the credentials.
In case the data is confidential, and the story needs to be shared with the entire team, Tableau Server comes in handy. To publish a story to Tableau Server, Select Select Server > Publish Workbook or click Share on the toolbar. But make sure to create an account first.
That's all we need to create a good visualization in Tableau although, one might find doing a lot more revising in each stage than we did here. So with experimentation and practice, tableau becomes a lot more familiar and will unleash amazing features to help us analyze and present data. Please comment below in case of any queries or questions and Happy Visualizing.
Check out our Creating Tableau Visualizations Using AirBnB Dataset Tutorial.
Tutorial
Tutorial
Tutorial
Courses in Tableau
Course
Start your Tableau journey with our Introduction to Tableau course. Discover Tableau basics such as its features and dashboards.
Course
Take your Tableau skills up a notch with advanced analytics and visualizations.
Course
Dashboards are a must-have in a data-driven world. Increase your impact on business performance with Tableau dashboards.
Our goal as Data Analysts is to arrange the insights of our data in such a way that everybody who sees them is able to understand their implications and how to act on them clearly.
Tableau is a data analytics and visualization tool used widely in the industry today. Many businesses even consider it indispensable for data-science-related work. Tableau's ease of use comes from the fact that it has a drag and drop interface. This feature helps to perform tasks like sorting, comparing and analyzing, very easily and fast. Tableau is also compatible with multiple sources, including Excel, SQL Server, and cloud-based data repositories which makes it an excellent choice for Data Scientists.