Data Visualisation with Tableau
Learn how to analyze and display data using Tableau and make better, more data-driven decisions.
Originally published at Datacamp
This article was published in 2018. A lot of changed in Tableau since then. It is recommended to go through the latest documentation of Tableau for the latest features and enhancements.
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.
This tutorial will cover the following topics:
- Introduction to Tableau
- Getting Started
- Emphasizing the Results
- Map View
- Dashboard
- Story
- Tableau’s integration with R, Python and SQL
- Saving the Work
1.Introduction to Tableau
Overview
Tableau Software is an American computer software company headquartered in Seattle, WA, USA. It generates interactive data visualization products which focused on BI. The company was established at Stanford University’s Department of Computer Science between 1997 and 2002.
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
Installation
Depending upon the choice of product, download the software on to the computer. The installation is a very straightforward process in which you need to accept the license agreement. You can verify the installation by clicking the Tableau Icon. If the following screen appears, you are good to go.
2.Getting Started
In this section, we will learn some basic operations in Tableau to get acquainted with its interface.
Tableau Workspace
The Tableau workspace consists of menus, a toolbar, the Data pane, cards and shelves, and one or more sheets. 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.
Connecting to a Data Source
Before we can build a view and analyze our data, Tableau must be first connected to the intended data. Tableau supports connection to a wide variety of data, stored in a variety of places. For example, your data might be stored on your computer in a spreadsheet or a text file, or in a big data, relational, or cube (multidimensional) database on a server in your enterprise. Or, you might connect to public domain data available on the web such as U.S. Census Bureau information, or to a cloud database source, such as Google Analytics, Amazon Redshift, or Salesforce.
When you launch Tableau Desktop, the data connectors that are available to you are listed on the Connect
pane, which is the left pane on the Start page
. File types are listed first, then common server types, or servers that you’ve recently connected to. Click More
to see the complete list of data connectors you can use. UnderOpen
, you can open workbooks that you have already created. Under Sample Workbooks
, view sample dashboards and worksheets that come with Tableau Desktop. Under Discover
, find additional resources like video tutorials, forums, or the “Viz of the week†to get ideas about what you can build.
Hands On
For supported files and databases, Tableau provides built-in connectors that are built for and optimized for those types of data. If your file or database type is listed under Connect, use this named connector to connect to your data. If your file or database type is not listed, you might have the option of creating your own connection using Other Databases (ODBC) or Web Data Connector. Tableau provides limited support for connections that you create using either of these options.
Connecting to the Sample-Superstore data set
For convenience, let's use the sample data set that comes with Tableau installation named sample superstore.xls.However, in this tutorial, we will download it from here and load it as an excel sheet. The data is that of a United States Superstore. It contains information about products, sales, profits, and so on that you can use to identify key areas for improvement within this fictitious company.
Steps
- Import 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. If you wish to view the exact changes that it made, click on Review the results, and choose the Orders tab in the opened Excel sheet. it will show, it simply removed the erroneous data.
Hands On
Creating a View
We will start by creating a simple chart. In this section, we will get to know our data and will start 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).
Row-level data rolled up to a higher category, such as the sum of sales or total profit. Tableau does this automatically so you can break data down to the level of detail that you want to work with.
Steps
- Go 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 in the Data pane, drag Order Date to the Columns shelf.
When you drag Order Date to the columns shelf, Tableau creates a column for each year in your data set. Under each column is an Abc indicator. This indicates that you can drag text or numerical data here, like what you might see in an Excel spreadsheet. If you were to drag Sales to this area, Tableau creates a cross-tab (like a spreadsheet) and displays the sales totals for each year.
- From Measures, drag Sales to the Rows shelf.
Tableau generates a chart with sales rolled up as a sum (aggregated). Total aggregated sales for each year by order date is displayed.Tableau always generates a line chart for a view that includes time (in this case Order Date)
Hands On
This line chart shows that sales look pretty good and seem to be increasing over time. This is good information, but it doesn’t really tell you much about which products have the strongest sales and if there are some products that might be performing better than others. Let us see what else you can find out.
Refining the View
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.
Steps
- From Dimensions, drag
Category
to the Columns shelf and place it to the right ofYEAR(Order Date)
.The view updates to a bar chart. By adding a second discrete dimension to the view, data changes into discrete chunks instead of continuous. This creates a bar chart and shows the overallSales
for eachProduct
category 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 2017:
- To add data point information as labels to your view, click
Show Mark Labels
on the toolbar.
- To display the bar chart horizontally instead of vertically, click Swap on the toolbar.
- The view above nicely shows
sales
bycategory
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 very broad category and consists of many different items. How can we identify which furniture item is contributing towards maximum sales?
To help answer that question, we decide to look at products by sub-category
to see which items are the big sellers. For example, for the Furniture category, you want to see details about bookcases, chairs, furnishings, and tables. Double-click or drag the Sub-Category dimension to the Columns shelf.
The sub-category is another discrete field. It creates another header at the bottom of the view and shows a bar for each sub-category
(68 marks) broken down by category and year. However, it is a lot of data to visually make sense of. In the next section, we will learn about filters, color and other ways to make the view more comprehensible.
Hands On
3. Emphasise the Results
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.
Adding filters to the view
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.
Steps
In the Data pane, under Dimensions, right-click Order Date and select Show Filter.Repeat for Sub->category field also.
Filters are card types and can be moved around on the canvas by clicking on the filter and dragging it to another location in the view
Adding colors to the view
Colours can be helpful in the visual identification of a pattern.
Steps
In the Data pane, under Measures, drag Profit to Color on the Marks card.
It can be clearly seen that Bookcases, Tables and even machine contribute to negative profit i.e loss. A powerful insight.
Hands On
Key Findings
Let’s take a closer look at the filters to find out more about the unprofitable products.
Steps
- In the view, in the
Sub-Category
filter card, clear all of the check boxes exceptBookcases, Machines,
andTables
. This throws an interesting fact. While in some years, Bookcases and Machines were actually profitable. However, in 2016, Machines became unprofitable. - Select
All
in theSub-Category
filter card to show all sub-categories again. - From Dimensions, drag
Region
to theRows
shelf and place it to the left of Sum(Sales). We notice that machines in the South are reporting a higher negative profit overall than in your other regions. - Let us now give a name to the sheet. At the bottom-left of the workspace, double-click
Sheet 1
and typeSales by Product and Region
. - In order to preserve the view, Tableau allows us to duplicate our worksheet so that we can continue in another sheet from where we left off.
- In your workbook, right-click the
Sales by Product and Region
sheet and selectDuplicate
and rename the duplicated sheet toSales-South
. - In the new worksheet, from Dimensions, drag
Region
to theFilters
shelf to add it as a filter in the view. - In the Filter Region dialogue box, clear all check boxes except South and then click
OK
. Now we can clearly focus on sales and profit in theSouth
. We find that machine sales had a negative profit in 2014 and again in 2016. We will investigate this in the next section - Lastly, do not forget to save the results by selecting
File > Save As
. Give your workbook a name, likeRegional Sales and Profits
.
Hands On
4.Map View
Creating a Map View
Map views are very helpful when we are looking at geographic data (the Region field). In the current example, Tableau automatically recognizes that the Country, State, City, and Postal Code fields contain geographical information.
Steps
- Create a new worksheet.
- Add
State
andCountry
under Data pane toDetail
on the Marks card. We obtain the map view. - Drag
Region
to theFilters
shelf, and then filter down to theSouth
only. The map view zooms in to the South region, and there is a mark for each state. - Drag the
Sales
measure toColor
on the Marks card. We obtain a filled map with the colors pointing to the sales in each state. - We can change the color scheme by clicking
Color
on the Marks card and selectingEdit Colors
. We can experiment with the available palettes. - We observe that Florida is performing the best. Hovering over its mark reveals a total of 89,474 USD in sales, as compared to South Carolina, for example, which has only 8,482 USD in sales. Let us gauge the performance by
Profit
now since Profit is a better indicator than sales alone. - Drag
Profit
toColor
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 Map
Hands On
Getting into the details
Maps are great for visualizing the data broadly. In the last step, we discovered that we discovered that Tennessee, North Carolina, and Florida have a negative profit. In this section let us draw a Bar chart to explore the reason for the negative profit.
Steps
- Duplicate the Profit Map worksheet and name it Negative Profit Bar Chart.
- In the Negative Profit Bar Chart worksheet, click Show Me and then select horizontal bars. Show Me highlights different chart types based on the data you’ve added to your view.
- Multi-select the bars on the left by clicking and dragging your cursor across the bars between Tennessee, North Carolina, and Florida. On the tooltip that appears, select Keep Only to focus on those three states.
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.
- In the Data pane, drag a field and drop it directly on top of another field or right-click the field and select
- Drag any additional fields into the hierarchy. You can also re-order fields in the hierarchy by dragging them to a new position. In the current viz. we will create the following hierarchies: Location, Order and Product.
- On the Rows Shelf, click the plus icon on the
State
Field to drill-down to theCity
level of detail - That’s a lot of data. We can use
N-Filter
to filter to reveal the poorest performers. From the Data pane, dragCity
to the Filters shelf. Click By field and then Click theTop
drop-down and selectBottom
to reveal the poorest 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 views “Jacksonville, North Carolina” that doesn’t belong 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) (Country, State) set and select Add to Context. We find that now Concord, North Carolina appears in view while Miami, Florida disappears which makes sense.
- But Jacksonville, North Carolina is still in the view which is incorrect. On the Rows shelf, click the plus icon on City to drill down to the Postal Code level of detail. Right-click the postal code for Jacksonville, NC, 28540, and then select Exclude.
- Drag Postal Code of the Rows shelf. This is the final view.
Hands On
Key Findings
Let us now focus only on the loss-making entities i.e the Products and also let us identify the locations where such products are sold.
Steps
- Drag Sub-Category to the Rows shelf.
- Drag Profit to Color on the Marks card. This enables us to quickly spot products with negative profit.
- In the Data pane, right-click Order Date and select Show Filter.It seems that Machines, tables, and binders don’t seem to be doing well. So should we stop selling those items in Jacksonville, Concord, Burlington, Knoxville, and Memphis? Let’s verify.
- Go back to the Profit Map sheet tab.
- On the Data pane, right-click Sub-Category and select Show Filter.
- From Measures, drag Profit to Label on the Marks card.
- On the Data pane, right-click Order Date and select Show Filter to provide some context for the view. Clear Binders, Machines, and Tables from the list on the Sub-Category filter card in the view.
Hands On
5. Dashboard
A dashboard is a collection of several views, enabling one to compare a variety of data simultaneously.
Creating a Dashboard
Steps
- Click the
New dashboard
button. - Drag
Sales in the South
to the empty dashboard - Drag
Profit 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. - On Sales in the South, right-click in the column area under the
Region
column header, and clearShow
Header. Repeat the same forCategory
row header. This helps to show only what is needed and hiding unnecessary information. - Right-click the
Profit Map
title and selectHide Title
. Repeat the same forSales in the South
view. - Select the first
Sub-Category
filter card on the right side of your view, and at the top of the card, click theRemove
icon. Repeat this step for the secondSub-Category
filter card and one of theYear of Order Date
filter cards. Click the drop-down arrow at the top of theYear of Order Date
filter, and selectSingle Value (Slider)
.Now let the magic unfold. Try selecting different years on the Year of Order Date filter and see how the data is quickly filtered to show that state performance varies year by year. - Drag the
SUM(Profit)
filter and drag it at the bottom of the dashboard below Sales in South.
Hands On
Adding Interactiveness
In order to make the dashboard more interactive like viewing which sub-categories are profitable in specific states, few changes need to be done.
Steps
- Select
Profit Map
in the dashboard, and click theUse as filter
icon in the upper right-hand corner - Now if we select any state in the map, the Sales in the
South chart
updates to show just the sub-category sales. - Select the
Year of Order Date
filter, click its drop-down arrow, and selectApply to Worksheets > Selected Worksheets
. - In the
Apply Filter to Worksheets
dialog box, selectAll
in the dashboard, and then clickOK
. This is done in order to apply the filter to all worksheets in the dashboard that use this same data source. - Now explore and experiment. In the viz. below we will filter
Sales in the South
to only items sold in North Carolina, and then explore year by year profit. - Rename the Dashboard to
Regional Sales and Profit
.
Hands On
Thus, selling machines in North Carolina did not bring any profits to the company.
6. Story
A dashboard is a cool feature but tableau also offers us to showcase our results in presentation mode in form of stories about which we will discuss in this section.
Building a Story
Steps
- Click the
New story
button. - From the Story pane on the left, drag the
Sales in the South
worksheet onto your view. - Edit the text in the gray box above the worksheet. This is the caption. Name it as
Sales and profit by year
. - Stories are quite specific. Here we will tell a story about selling machines in North Carolina. In the Story pane, click
Duplicate
to duplicate the first caption. - In the
Sub-Category
, filterselect
onlyMachines
. This helps to gauge sales and profit of machines by year. - Rename the caption to
Machine sales and profit by year
.
Hands On
Making a Conclusion
It is clear that machines in North Carolina are leading to a loss of profit. However, this cannot be demonstrated by looking at Profit and Sales on the whole. For this, we need regional Profit.
Steps
- In the Story pane, select
Blank
. Drag the dashboardRegional Sales and Profit
onto the canvas. - Caption it as
Low performing items in the South
. - Select
Duplicate
to Create another story point with your Regional Profit dashboard. Select North Carolina on the bar chart. - Select All the years.
- Add a caption, for example,
Profit in NC, 2013-2016
. - Select any year like 2014. Add a caption, for example,
Profit in NC, 2014
and then click Duplicate. Repeat the same for all the remaining years. - Click on the presentation mode and let the
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.
7. Tableau’s integration with R, Python & SQL
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 also with DBMS like SQL. This offers increased advantages in terms of 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 visualisations which are far more superior than that of these languages. Also the visualisation 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.
1. Tableau and R
R is a popular statistical language used to perform sophisticated analysis and predictive analytics, such as linear and nonlinear modeling, statistical tests, time-series analysis, classification, clustering, etc. Using Tableau in conjunction with R has the following advantages:
- Gives Tableau users access to a rich, ever-expanding collection of statistical analysis and data mining libraries to help them gain deeper insights from their data.
- Brings Tableau’s fluid data exploration experience and broad connectivity options to R users.
- Enables consumers of Tableau worksheets and dashboards take advantage of R, simply by interacting with the visualization or widgets without the need to have any knowledge of the language.
How does Tableau integrate with R?
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. The results are then returned back to Tableau for use by the Tableau visualization engine.
Setting up Tableau Desktop with R
- Download and Install
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’)
Connect Tableau to the R Server
Once Rserve
is installed, open Tableau Desktop and follow the steps below
- Go to the
Help > Settings and Preferences and select Manage External Service Connection
- Enter a server name of Localhost (or 127.0.0.1) and a port of 6311.
- Click on the Test Connection button to make sure everything runs smoothly. You should see a successful message. Click OK to close.
Start using the R scripts in Tableau
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.
Steps
- Open Tableau workbook and connect to the sample superstore data.
- Connect to Rserve. Once tableau desktop is connected to Rserve it can invoke the R engine through calculated fields.
- We will now create a calculated field called Expected Profit.
There are four functions that are available for use with R and they all begin with the word script. The functions are:
SCRIPT_REAL: returns Real numbers as results
SCRIPT_STR: returns string
SCRIPT_INT : returns integers
SCRIPT_BOOL: returns booleans
- For this example, we are going to use the SCRIPT_REAL function. We are going to create a simple
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 to. 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 theaverage unit price, average order quantity
andaverage 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 dragExpected 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 very powerful language because of its power to easily forecast, utilising widely-used libraries that contain well-known algorithms. 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 visualisations.
2. Tableau and Python
Python is a widely used general-purpose programming language, and a large number of Python libraries are available to perform statistical analysis, predictive models or machine learning algorithms. Connecting Tableau with Python is one of the best approaches for predictive analytics. Tabpy
is a package developed to do the same. Tableau can connect to the TabPy server to execute Python code on the fly and display results in Tableau visualizations.
How does Tableau integrate with Python?
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.
Setting up Tableau Desktop with Python
Download and Install Tabpy
.
Running Python code within a Tableau workbook requires a Python server to execute it, and the TabPy framework gets the job done. Download TabPy from Github at the following link. Alternatively, you can follow the steps below:
conda install -c anaconda tabpy-server
Then cd to the directory containing the downloaded tabpy
server and run
python setp.py
Connecting Tableau with TabPy
The next step is to connect Tableau with TabPy. This can be done in Help > Settings and Performance > Manage External Service Connection:
Test the connection and you should get a successfully connected
prompt.
Start using the Python scripts in Tableau
This new Python integration in Tableau enables powerful scenarios. For example, it takes only a few lines of Python code to get the sentiment scores for reviews of products sold at an online retailer. Then one can explore the results in many ways in Tableau. Let us see this with an example
Sentiment Analysis with Tabpy
We will be using the mobile reviews dataset which can be downloaded from here.
Steps:
- Import the dataset into Tableau Desktop
- Connect to Tabpy. Once Tableau desktop is connected to
Tabpy
it can invoke 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 to this tool you will need to install it first.Please read more at their github page.
- Now, drag
Reviews
onto rows andSentiment
onto Label 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 visualise the results too. The positive reviews are in increasing order of green while the negative ones are in red.
Thus, we have seen how it takes only a few lines of Python code to get the sentiment scores for reviews of products sold at an online retailer. Then we can explore the results in many ways in Tableau. We might filter to see just the negative reviews and review their content to understand the reasons behind them or we might visualize overall sentiment changes over time.
3. Tableau and SQL Server
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 optimised, 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 recognises 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 visualisations.
Steps:
- Login to the SQL Server
- Open Tableau Desktop and under Servers, connect to MS SQL.
- Paste the server name in the dialog box that opens and click
ok
. This connects Tableau to the SQL Server. Select the database of choice. In this example, we choose the sales DB. We can then select from a list of TABLES too eg Sales Log. The table gets imported into the Tableau environment. Now we can choose to extract the entire data or the portion of it to a new worksheet. We can even specify the number of rows to extract. - In the new worksheet we have the extracted data from MS SQL, From here we can work with it like any other Tableau Worksheet.
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.
8. Saving the work
Tableau Desktop
To save a Tableau workbook locally, Select File > Save. Specify the workbook file name in the Save As
dialog box. Tableau saves the file with the .twb extension by default.
Tableau Public
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.
Tableau Server
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.
Conclusion
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 practise, 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 Visualising.