Book Image

Tableau Cookbook - Recipes for Data Visualization

By : Shweta Sankhe-Savale
Book Image

Tableau Cookbook - Recipes for Data Visualization

By: Shweta Sankhe-Savale

Overview of this book

Data is everywhere and everything is data! Visualization of data allows us to bring out the underlying trends and patterns inherent in the data and gain insights that enable faster and smarter decision making. Tableau is one of the fastest growing and industry leading Business Intelligence platforms that empowers business users to easily visualize their data and discover insights at the speed of thought. Tableau is a self-service BI platform designed to make data visualization and analysis as intuitive as possible. Creating visualizations with simple drag-and-drop, you can be up and running on Tableau in no time. Starting from the fundamentals such as getting familiarized with Tableau Desktop, connecting to common data sources and building standard charts; you will walk through the nitty gritty of Tableau such as creating dynamic analytics with parameters, blended data sources, and advanced calculations. You will also learn to group members into higher levels, sort the data in a specific order & filter out the unnecessary information. You will then create calculations in Tableau & understand the flexibility & power they have and go on to building story-boards and share your insights with others. Whether you are just getting started or whether you need a quick reference on a “how-to” question, This book is the perfect companion for you
Table of Contents (18 chapters)
Tableau Cookbook – Recipes for Data Visualization
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Building our first visualization and understanding the Tableau workspace


Tableau is a very user-friendly tool that helps us visualize our data with a simple drag and drop technique. In the previous recipe, we saw how to connect to the data, and in this section, we will create our very first visualization and get acquainted with the Tableau workspace.

Getting ready

We will continue from where we left in the previous recipe where we are still connected live to the Orders sheets of Sample - Superstore.xls. Let's quickly build our first view and then understand the workspace of Tableau.

How to do it...

  1. If you haven't already connected to the data, then make sure that you are connected live to the Orders sheets of Sample - Superstore.xls by following the steps mentioned in the previous recipe.

  2. Click on the Go to Worksheet option and then the Sheet 1 tab. Refer to the following image:

  3. Once we do this, we will get a view as shown in the following image:

  4. Then, let us drag Region field from the left-hand side pane and drop it into the Rows shelf. Refer to the following image:

  5. Once you do this, drag Sales and drop it into the Columns shelf, and our view will be updated as shown in the following image:

  6. What we see in the preceding image is a bar chart that shows region-wise Sales.

How it works...

After having established the connection to the data and having read the data in Tableau by clicking on the Go to Worksheet option and then the Sheet 1 tab, we get the view where we will create our visualizations. Refer to the following image:

The preceding image gives us a quick glimpse into the Tableau workspace. Let's understand this workspace in more detail:

  • Workbook name: Refer to the number 1 in the preceding image. This is the name of the workbook. By default, it is Tableau – Book 1 or so. However, we can change the name once we save the workbook.

  • Go to the start page: Refer to the number 2 in the preceding image. This helps us navigate back to the start page of Tableau.

  • Toolbar: Refer to the number 3 in the preceding image. This is Tableau's toolbar that consists of various commands that help us enable/disable various features and functionalities.

  • Side bar: The number 4 in the preceding image refers to the sidebar that provides two panes: the Data pane and the Analytics pane.

The Data pane, as the name suggests, shows the data to begin with, which is populated from the data source that we have connected to. The top section of the Data pane displays the data source that we have connected to. In the case of multiple data sources, we will see a list of data sources.

Further, just below the data source section are the fields available in that data source. Refer to the following image:

The Data pane is primarily divided into two sections: Dimensions and Measures.

Dimensions are all the descriptive fields in our data. These are fields that hold categorical/discrete qualitative data. In short, any field that contains text or date values will be identified as Dimensions, for example, customer name, purchase date, customer state, and so on.

On the other hand, Measures are all the fields that contain numeric values. These are fields that hold quantitative data, for example, sales, profit, budget, and so on. Typically, Measures are the fields that will be aggregated while analyzing. For example, we may want to see the sum of sales across regions, the average sales for a particular category, and so on.

Basically, Dimensions and Measures are Tableau's way of classifying our data fields. At a little later point in time, you will understand how Tableau is capable of doing this classification, and in case we wish to change it, then how to go about it.

Further, the Data pane may additionally accommodate sections for Sets and Parameters, functionalities that we will explore later.

The Analytics pane, on the other hand, provides quick and easy access to features such as reference lines, box plots, trend lines, forecasts, and so on. We will explore these options at a later stage. To begin with, the Analytics pane may be disabled/grayed out. However, once we start creating our visualizations, then depending on the visualization, some of the options from this pane will be enabled/disabled for us. Refer to the following image:

  • Go to the data source page: Refer to the number 5. This helps us navigate back to the data source page of Tableau.

  • Status bar: Refer to the number 6. The status bar shows us the number of rows and marks that we are dealing with. It also displays occasional warning icons.

  • Worksheet tabs: Refer to the number 7. The worksheet tab helps us view our worksheets, dashboards, or story. These can either be shown as tabs or filmstrips.

  • Worksheet view: Refer to the number 8. The worksheet view is the place where we build a view/visualization.

  • Cards and shelves: Refer to the number 9. These are containers for shelves, such as the Column shelf, the Row shelf, the Filter shelf, and the Page shelf. This is where we define what the columns, rows, and filters of our worksheet are. The Marks card consists of a drop-down list that helps us specify the mark type (for example, bar, line, pie, circles, and many more) and also contains shelves for Color, Size, Text, Detail, and Tooltip. This is where we can define the appearance of our worksheet in terms of the visualization type, color scheme, labels, and many more. Depending on what kind of chart we create, we would see the Label shelf, the Shape shelf, the Path shelf, and the Angle shelf as well. However, the availability of these shelves is dependent on the visualization that we create. Refer to the following image to see the options from the Marks dropdown:

We shall explore these various shelves in more detail as we progress with our understanding of Tableau.

In the earlier section, we read about Dimensions and Measures. As a quick recap, Dimensions are basically fields that contain categorical/descriptive/qualitative data, such as text and dates, whereas, Measures are fields that contain numeric/quantitative data that can be aggregated.

Dimensions and Measures are the fundamental building blocks of our analysis, and it is very important that they are identified correctly. As mentioned earlier, Tableau is capable of classifying our data fields as either a Dimension or a Measure, and it does so based on the data type of the fields.

So, what data types are supported by Tableau and how does Tableau identify them? When we connect to a database, the data types are already defined in the database and that is what Tableau would read. However, when we connect to typical flat file formats, such as Excel, Access, or CSVs, Tableau will read the data types of the first 10,000 rows of an Excel data source or the first 1,024 rows of a text file data source. Once it does this, it will accordingly decide the data type of that field. So, in an Excel file, if most of the first 10,000 rows are numeric values, the entire column is mapped as Integer.

Tip

Before version 8.2 came out, Tableau used Microsoft Jet Engine to connect to Excel, Access, and CSVs. We call this a legacy connection. However, with the latest versions, there are new connectors that are being used for connectivity to Excel and CSVs. With the legacy connection, the datatype mapping was done by reading the first 16 rows of the data for Excel, Access, and CSVs.

Each field under the Dimensions and Measures section will have a prefixed icon before it. These are the data types supported by Tableau and are identified in the Data pane by one of the following icons:

Is it possible to change the datatype of the fields in Tableau? Yes! Ideally, it is recommended that we handle all the data-related changes at the data source level. However, if we feel that Tableau has incorrectly identified the data type of a certain field, then we can right-click on the field in the Data pane, select Change Data Type, and then select the appropriate data type. Refer to the following image:

Once Tableau identifies the data type, it simply classifies all String and Date / Date & Time data types as Dimensions and all Integer data types as Measures.

Why is Row ID a Dimension even though its datatype is Integer? Even though Row ID is a numeric field in this case, taking a sum or average of Row ID won't be useful. It is actually a descriptive field that gives us information about the transaction. Since the header/field name contains the word ID, Tableau assumes that it is an identifier and hence places it in the Dimensions shelf.

Is it possible to convert a Dimension to a Measure and vice versa? Yes! It is easily possible to convert Dimension to Measure and vice versa. To do so, we can simply right-click on the Dimension field and select the option of Convert to Measure. If we right-click on the Measure field, then we get an option of Convert to Dimension. Refer to the following image:

We can also drag Dimension fields and then drop them into the Measures pane and vice versa to convert them from Dimensions to Measures. The same method can be used to convert Measures to Dimensions as well.

When we connect to the data, apart from reading the data fields and classifying them as Dimensions or Measures, Tableau also autogenerates certain new fields in both the Dimensions and Measures pane. They are as follows:

  • Measure Names: This contains the names of all our measures in a single dimension and is shown at the bottom of the Dimensions pane.

  • Measure Values: This contains the values of all our measures into a single field and is shown at the bottom of the Measures pane.

  • Number of Records: This shows the number of records that we are dealing with after we have connected to our data.

  • Latitude and Longitude: Tableau has the ability to create geographic maps and plot any point on a Map; we would essentially require the latitudes and longitudes of these geographic points. Tableau understands certain geographic roles and will automatically generate these two measures if it identifies any field as a geographic field. We will revisit this in more detail when we discuss Maps in the later chapters.