The world’s leading publication for data science, AI, and ML professionals.

Tableau visualizations

Learn how to create basic charts in Tableau

Photo by Scott Graham on Unsplash
Photo by Scott Graham on Unsplash

What is tableau?

Tableau is an end-to-end, powerful, secure, flexible, interactive visual analytics software that is used in Business Intelligence industries. It is transforming the way we use data to discover and resolve problems. It is known to be one of the fastest growing Data Visualization platforms. What it essentially does is, it converts raw data into an intelligible visualization that many individuals and organizations use for analysis of problems and decision making.

Why should you use tableau?

  • Firstly, performing data analysis using Tableau is a quick and convenient process.
  • It’s visualizations are easy to comprehend. Because of its user friendliness, people at any position in an organization will find it facile to use.
  • Not only are its visualizations easy to view, they are also easy to create. Anyone with a technical or even nontechnical background can create visualizations using Tableau.
  • Data blending and real time analysis are a few of Tableau’s many substantial features.
  • It’s a software that can be applied to any business in order to gain lucid insights.
  • Tableau offers support for hundreds of data connectors. The list of which can be found here.
  • Tableau has a huge community that is especially active on Twitter where people use hashtags such as #MakeOverMonday
  • The dashboards created can be shared as a dynamic visualization. If dynamic visualizations aren’t supported on a given platform then one also has the option of exporting it as a static visualization.

If you’re still not sure if Tableau is the way to go for you, I suggest you read the following article: Excel, Tableau, Power BI… What should you use?

Tableau Products:

Let’s get started with this tutorial.

Signing up for a Tableau Public Account

a. Go to public.tableau.com

b. Click sign up on the top right

c. Fill in your details and note them down

Installing the 14 day fully free trial of Tableau

a. Go to Tableau Desktop: https://www.tableau.com/products/trial

b. Enter your Email address and download the free trial. If you’ve a student or teacher account, you can get a one year free license.

c. Once the application is downloaded, register yourself.

You can find the resources to this tutorial here.

Let’s launch the application and explore the main components of the application.

When one first opens the Tableau Desktop application, the following window appears. On the left pane of this window we have different options to connect with different data sources like Tableau Server (where you can publish your reports directly to the server), Microsoft Excel, JSON File, Microsoft SQL Server, Google Analytics, MariaDB, MySQL, etc.

At the bottom, tableau provides some sample workbooks that provide an introduction.

In the right pane we have some training resources that will help you get better acquainted with Tableau, it’s services and functionalities.

Prepare data

For this tutorial we will be importing our data which is an excel file

After importing our data, the window that appears is called a data source window.

On the left we have ‘Connections’ which shows you the data sources you can connect to. You can update, edit or delete the selected data sources in the Connections section.

The next section is the ‘Files’ section which usually shows you the table within the data source.

Under that we have a Union function that allows you to append data into your table. For example, if you had 2 similar data files of employees, you can use the union option to merge them.

To the right of the Union option we have the preview of the table

Above every field name, we have an icon that represents the field type which is identified by Tableau itself and can be modified by clicking on it.

On the top right corner we’ve another Connection Option. Here Tableau allows us to choose the type of connection we want to make with our data: Live or Extract.

By default the Live option will be selected. When you select ‘Extract’, the Filter option appears which is a very important functionality. Using filters we can build data on specific data that we have filtered in which means that we can’t use the data that we have filtered out.

To add a filter

a. Click on ‘Add’ in the top right corner.

b. Click on the add button of the window that appears.

c. Choose the field that you want to use in the filter. Eg: City

d. Select the value in the chosen field that you want to filter in and click ‘OK’

To edit/remove a filter

a. Click on ‘Add’ in the top right corner

b. Click on the added field that you want to edit/remove in the window that appears.

c. Select the ‘Edit’ or ‘Remove’ button according to the operation that you want to perform.

d. Click on ‘Ok’.

Now that we’ve understood how filters work, let’s move on with the tutorial and start creating charts.

Select the ‘Sheet 1’ option in the lower left bottom of the window and select the location where you want to store your extracts.

Now, to the left we can see the data source that we’re connected to. When you right click on your data source, you have various options available like refresh, edit, duplicate, etc.

Under that, we’ve two more panes: Dimensions and Measures

Dimensions, generally in blue, contain data that is in categories of segments. You can’t perform mathematical operations on them. For example, you can’t multiply two categories.

Measures, generally in green, are an opposite of Dimensions. Which means that here we can multiply two fields.

You can move a measure to a dimension by right clicking on it. Here, we’ll right click and move ‘Sales Agent ID’ to Dimensions from Measures

Note that fields like Latitude and Longitude do not exist in our dataset but have been automatically added by Tableau upon reading fields such as City, State, Region, etc.

Creating charts

The simple way to do it is to drag the categories into the ‘Row’ and ‘Column’ fields.

Let’s drag the ‘Region’ category into the Rows and the ‘Sales’ Category into Columns. Tableau then automatically creates a bar chart for us.

On the top right corner of Tableau Desktop we have the ‘Show Me’ option where Tableau displays the various types of charts that we can visualize our data with.

To clear your sheet, you can click on the ‘Clear Sheet’ Icon.

To Undo or Redo actions on your chart, you can click the arrow buttons in the top left corner of the application.

Let’s now create a visualization to view Sales by Month.

First, drag ‘Order Date’ to Columns, click on the arrow next to it and select ‘Month’ as we want to view our Sales by Month.

You may notice that there are 2 sections of Year, Quarter, Months, etc. The first section represents just one part of the date but the second section shows the Month along with the year, so we shall select the Month from the second section.

The column field previously was blue, now it has changed to green. This is because we changed the Year to the Month. Blue indicated that the field is discrete and green indicates that it is continuous. Continuous basically means unbroken data points. And as time is continuous, it’s green whereas a field like Category would be green, as categories are not related to each other, they are discrete.

Moving on, to display our Sales by Month we need to drag our ‘Sales’ category into the Rows field. When you do this, Tableau automatically adds the ‘SUM’ operation to the Sales category which basically means that it’s taking a summation of each of the rows of your dataset. To view other operations to perform on your dataset field besides SUM, click on the arrow next to it. For now we shall leave the operation to be a SUM.

Next, let’s change the visualization in a way that the user can see the Sales by Month of a particular year. To do that, we need to filter our data set on year so drag the Order ID field onto the ‘Filters’ Card and select Years. Then select the particular year that you, in our case that is 2019, the most recent one.

Let’s sort out our sales as it’s a currency. So go to the ‘Sales’ field under Measures, click on ‘Default Properties’ and select the ‘Number Format’ option as that is what we intend on changing. Then select ‘Currency (Standard)’ and select ‘English (United States)’ as our sales currency is in USD. After this, go to ‘Currency (Custom)’, change the Decimal places to 0, and click ‘Ok’. Your chart should appear as follows:

Next, let’s bring in an average line.

In the analytics pane at the top left corner of your window, drag the ‘Average Line’ option into the Table option that appears in a window.

To further customize this line, click on the line and go to edit. Choose a Custom Label and type in ‘Average:

Further you can go select the type of line, it’s color, etc.

Changing the title of the sheet dynamically

Double click on ‘Sheet 1’ in the chart. Clear the current data. Write ‘Sales for ‘ and to add a dynamic date ahead of it, click on insert in the top right corner of this window, and select the ‘YEAR(Order Date)’.

Moreover, you can change the font type or size of the title, make it bold and center align it as well.

To check if our dynamic title works or simply view the data of a different year, right click on the ‘YEAR(Order Date)’ filter and select the ‘Show Filters’ option. Select or unselect any year to view how the title works dynamically according to the chosen year.

Customizing the chart

In the Marks Pane, we can change the color and size of our line.

To add labels on each point, drag and drop the ‘Sales’ Measure in the ‘Label’ field under Marks. To modify the label, right click on it, go to format, click on ‘Numbers’ under Default, go to Currency (Custom), change the Decimal values to ‘0’ and the data prefix to ‘$’.

Moving on to customizing the labels, right click on ‘Label’ under the Marks pane and edit the font in the ‘Font’ section as shown in the video below.

To further customize the chart, right click anywhere on it and select the ‘Format’ option. You can change the font style under the ‘Worksheet’ field of the Format pane. There are many more functionalities that you can go ahead and explore in this section.

Besides this section’s icon we have the Alignment section, followed by the Shading section. In the shading section you can change the background color of the chart.

To remove the gridlines, click on the ‘Lines’ option and change the ‘Grid Lines’ field to None.

Adding a new sheet

First, let’s rename our current sheet to ‘Sales by the years’ by double clicking on it. You can add a new sheet by clicking on the new sheet button that is to the right of our current sheets name at the bottom of the window. However, for the sake of our tutorial we will right click on our current sheet and duplicate it. Let’s rename this duplicate chart as ‘Sales by Category’.

As the new sheet’s name suggests, we shall now create a different chart in this sheet. Remove the MONTH(Order Date) and SUM(Sales) fields from the Columns and Rows section. Instead, drag the SUM(Sales) and Category fields from the left pane to the Columns and Rows section, respectively. This automatically creates a bar chart for you (If not, select the bar charts option under the Show Me section in the top right corner of the window).

Now, we can increase the width of the bars by changing the fit of the chart from Standard to Entire view in the top pane as shown below.

Again to add labels, drag the ‘Sales’ field to the ‘Label’ section under the ‘Marks’ pane

Notice that since we duplicated our sheet, the settings from the previous sheet are all still the same here. For instance, the text is bold, there are no gridlines, etc.

Another functionality of Tableau is that you can have the color of your bars vary according to the data. To understand this better, try dragging the ‘Sales’ measure to ‘Color’ under the Marks pane and it will appear as follows.

The bar with the lightest blue has the least sales and the bar with the darkest blue has the most sales. Tableau displays blue as the default color scheme here but we can easily choose different color combinations by clicking on ‘Color’ in the ‘Marks’ pane and editing the color. In order for it to match our previous chart, we shall select green as the color scheme for our bar charts.

To sort the bar charts, we have an ascending and descending option in the top pane.

Histograms

Duplicate the ‘Sales by Category’ sheet and rename it to ‘Products/order’. Drag out and remove all the fields except the ‘YEAR(Order Date)’ field in the Filters. Now let’s create a histogram to see if 2 or more products were sold in an order that was placed. For this, double-click on the ‘Quantity’ Measure and select ‘Histogram’ in the ‘Show me’ option. You want to make sure that the bin size is 2 so right click on the ‘Quantity (bin)’ Dimension and edit the size of the bins to 2.

What this histogram is telling us is that there were 337 orders where the quantity was between 0–2, 1450 orders where the quantity was between 2–4, and so on. Change the color of the histogram like we changed the color of our other charts earlier so that the theme of the dashboard that we create at the end is uniform. You can also add labels of the quantities by holding the Ctrl button and dragging the CNT(Quantity) from Rows to the label field under the Marks pane. Also, double click on the chart’s label since this is a different chart than the one that we duplicated this sheet from.

Maps

Duplicate the histogram sheet and rename it like we did earlier to ‘Sales Map’. Change the chart’s label to Sales Map as well. We need to create a hierarchy before getting started on our map as Tableau needs to know which is your state field and which country is that field linked to. For creating a hierarchy, drag the ‘State’, ‘City’ and ‘Postal code’ dimensions onto the ‘Country/Region’ dimension. Make sure you’re maintaining the hierarchy, i.e. first the ‘Country/Region’ dimension must appear, followed by the ‘State’, ‘City’ and the ‘Postal Code’. You can always drag and move these fields above or below each other in case of an error. Further, drag the hierarchy onto the ‘Detail’ field under the Marks pane. A map appears. You may also notice that the ‘Country/Region, States’ field appears in the Marks pane with a ‘+’ sign to it’s left. When you click on that, the next version of the hierarchy appears so let’s do that. Now double click on ‘Sales’ Measure to add the sales values to the map. At this point your map should look something like this:

We can also display our data on the map differently. Simply go to Show me and select the Maps chart. (The image above was a Symbols chart.) Like we did earlier, we can add the labels of the sales to our map by pressing the Ctrl button while dragging the Sales field (as that creates a duplicate of the field) that is already present in the Marks pane to Label. To further format this label, right click and select Format. In the Numbers Field under Default, change the Display Units to Thousands(K). Our map would now look some like this.

Cards

As always, duplicate the previous ‘Sales map’ sheet, drag out all the fields from the Marks pane as well as the rows and columns. Double click the Sales Measure, go to ‘Show Me’ and select the text table which should be the first option. Let’s customize this a bit. Change the Fit from Standard to Entire view in the top pane. In the marks pane click on ‘Text’ and increase the font size, change the Alignment to center. Now our Sales card is ready. You can create cards for different categories using the same method.

Creating a dashboard

To create a dashboard, click the ‘New Dashboard’ button at the bottom of the window.

All the sheets that you create will appear on the left side of the window. Let’s change the size of our dashboard to 1400px and 900px. Furthermore, if you wish to change the dashboards background color, you can go to the Dashboard option on the top of the window and select the format option.

To add your visualizations to the dashboard, simply drag and drop them onto the dashboard. To hide the visualization’s title/label, right click on it and select the Hide title option. And there you have it, your first Dashboard in Tableau

Currently our dashboard is displaying data of sales from 2019. If we add a filter, the user has the option of selecting the year and accordingly viewing all our visualizations subject to that specific year. To do this, click on any of the charts and under the filter option select ‘Year of Order Date’. This gives our filter. We can change it to a dropdown filter by clicking the arrow next to it and select the ‘Multiple Values dropdown’ option. To make sure this filter applies to every chart on selection of a particular year, right click on the filter and go to ‘Selected Worksheets’ under ‘Apply to Worksheets’, select the ‘All on dashboard’ option and you’re good to go.

Publishing the dashboard

Lastly, let’s publish our dashboard to Tableau public. To do so, click on ‘Server’ at the top of the window, enter your login details, name your dashboard.

That’s it for this article. I hope you enjoyed visualizing data with Tableau.

Thank you for giving it a read!


Related Articles