Professional Documents
Culture Documents
Mastering Tableau 2023 (2023 - 4th)
Mastering Tableau 2023 (2023 - 4th)
Preface
Improving Performance
Throughout this book, you will learn how to use various files and databases
to connect to Tableau Desktop and Prep Builder to easily perform data
preparation and handling, perform complex joins, spatial joins, unions, and
data blending tasks using practical examples. You will also get to grips with
executing data densification and explore other expert-level examples to help
you with calculations, mapping, and visual design using Tableau Exchange.
Later chapters will teach you all about improving dashboard performance,
connecting to Tableau Server, and understanding data visualization with
hands-on examples. Finally, you will cover advanced use cases such as self-
service analysis, time series analysis, and geo-spatial analysis, and connect
Tableau to Python and R to implement programming functionalities within
Tableau.
Finally, a brand-new chapter has been added that covers a very hot topic:
data governance. You will explore an introduction to important features of
Tableau Server that will get you prepared for compliance with GDPR and
other data privacy and governance regulations.
By the end of this Tableau book, you will have mastered Tableau 2023 and
you will be able to tackle common and advanced challenges in the data
analytics space.
Who this book is for
This book is designed for business analysts, business intelligence
professionals, and data analysts who want to master Tableau to solve a
range of data science and business intelligence problems. Prior exposure to
Tableau will help you get to grips with the features more quickly, but it is
not a prerequisite.
What this book covers
Chapter 1, Reviewing the Basics, takes you through the basic and essential
Tableau concepts needed to get you started.
Chapter 3, Using Tableau Prep Builder, discusses Tableau Prep Builder, the
not-so-little Extract – Transform- Load (ETL) brother of Tableau Desktop.
Chapter 4, Learning about Joins, Blends, and Data Structures, answers the
question of whether to use relationships, joins, or blends to combine data.
Chapter 10, Presenting with Tableau, shows tips and tricks on how to use
Tableau for presentation purposes.
Chapter 11, Designing Dashboards and Best Practices for Visualizations,
takes you through different formatting techniques and design rules to
maximize the aesthetics of your visualizations.
Chapter 12, Leveraging Advanced Analytics, will help you take your
analytical skills to the next level with three advanced use cases to follow
along with: self-service, time series, and geo-spatial analytics.
Chapter 14, Exploring Tableau Server and Tableau Cloud, covers the
different offerings and functionalities of Tableau Server, including Ask Data
and Data Details.
Conventions used
There are a number of text conventions used throughout this book.
Bold: Indicates a new term, an important word, or words that you see on the
screen, for example, in menus or dialog boxes, also appear in the text like
this. For example: “Place Profit_Expected on the Columns shelf, next to
Profit. Then click on either one and enable Dual Axis.”
Note
Warnings or important notes appear like this.
Pro Tip
Tips and tricks appear like this.
Get in touch
Feedback from our readers is always welcome.
Errata: Although we have taken every care to ensure the accuracy of our
content, mistakes do happen. If you have found a mistake in this book we
would be grateful if you would report this to us. Please visit,
http://www.packtpub.com/submit-errata, selecting your book, click Submit
Errata, and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on
the Internet, we would be grateful if you would provide us with the location
address or website name. Please contact us at [email protected]
with a link to the material.
Do you like to read on the go but are unable to carry your print books
everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version
of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code
from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts,
newsletters, and great free content in your inbox daily
This edition comes with new datasets, more examples of how to improve
dashboard performance, and the most up-to-date know-how on data
visualization, Tableau Server, and Tableau Prep Builder.
This new edition will also explore Tableau’s connections with Python and
R, Tableau extensions, joins, and unions, and last but not least, three new
use cases of powerful self-service analytics, time-series analytics, and geo-
spatial analytics in order to implement the learned content. By the end of
this book, you’ll have mastered the advanced offerings of Tableau and its
latest updates, up to Tableau version 2023.
Those who are fairly new to Tableau should find this chapter helpful in
getting up to speed quickly; however, since this book targets advanced
topics, relatively little time is spent considering the basics. For a more
thorough consideration of fundamental topics, consider Learning Tableau,
written by Joshua Milligan and published by Packt Publishing.
You can create your own profile—registration is free—and share all the
dashboards you’ve created that you think the world shouldn’t miss out on.
The best part, however, is that you can download all of them, open them in
your own version of Tableau, and start learning and replicating. Even
without your own profile or registration, it is possible to download
dashboards. In summary: Tableau Public is a free option but offers limited
data source connectivity, data privacy, and feature availability. It does
provide an excellent platform for sharing visualizations publicly though and
brushing up on your Tableau skills without the need for a paid license.
Creating worksheets
Before creating a worksheet, we’ll need to create a visualization to populate
it with. At the most fundamental level, a visualization in Tableau is created
by placing one or more fields on one or more shelves. As an example, note
that the visualization created in the following diagram is generated by
placing Number of Records on the Text shelf on the Marks card:
Having considered some basic theory, in the next subsection, you will get
the chance to follow along in your own Tableau workbook. Let’s go!
Creating a visualization
Now, let’s explore the basics of creating a visualization using an exercise:
1. Navigate to https://public.tableau.com/app/profile/marleen.meier to
locate and download the workbook associated with this chapter.
2. Open the file by double-clicking on the downloaded workbook.
3. In the workbook, find and select the tab labeled Fundamentals of
Visualizations:
5. Locate Sport within the Data pane, which can be found on the left-
hand side of the Fundamentals of Visualizations sheet:
Figure 1.4: Dimensions on the Data pane
6. Drag Sport to Color on the Marks card and click Add all members:
Figure 1.5: Dragging Color to the Marks card
10. Did you come up with any interesting visualizations? Feel free to
share them on Tableau Public. Add the tag #MasteringTableau if
you want other readers of this book to find them—sharing is caring!
If you are working on macOS, you can right-click on the pill after you’ve
dragged it to its location and then adjust the default behavior by changing
the measure. This works on Windows as well. Another option is to right-
click on the field while it is still in the Data pane on your left-hand side and
select Default Properties | Aggregation.
Now, let’s walk through an exercise where we’ll override another default
behavior on the Marks card:
In Figure 1.11, we can see the Number of Records over time (Year),
where each line represents one type of Sport. We chose to visualize this in
a stacked area chart.
Navigate to the Nested Sorting tab and try to sort the countries by the
amount of medals won, but separately for gold, silver, and bronze.
In Tableau, sorting and nested sorting can be done by simply clicking on the
icon next to each column name:
Figure 1.12: Sorting
To double-check the way of sorting, move your cursor onto the Country
pile until the arrow appears in the right corner, click on the arrow next to a
given field, in this case, Country, and select Sort…:
After having completed and understood Sort and Nested Sort, you will
immediately be able to add value to your dashboards by presenting values
in the most logical way. Now, we can move on to the next topic, the
different default chart types Tableau comes with: Show Me.
Show Me
Show Me can help users new to Tableau to create the visualization they are
looking for, such as bar charts, histograms, and area charts. It allows the
Tableau author to create visualizations from input data at the click of a
button. To understand how it works, let’s refer to the following screenshot,
which again makes use of the Overriding Defaults worksheet. This view
can be accessed by clicking the Show Me button in the upper-right corner
of any Tableau sheet:
Now let’s look at the following aspects that are highlighted in the preceding
screenshot:
Every icon in Show Me that isn’t grayed out represents a visualization that
can be created simply by clicking on it. For example, in the preceding
screenshot, Figure 1.15, the Tableau author may choose to click on the area
chart icon to create an area chart based on the selected and deployed fields.
Show Me options are highlighted based on two criteria: the selected fields
in the Data pane and the fields deployed in the view.
Creating dashboards
Although, as stated earlier in this section, a dashboard contains one or more
worksheets, dashboards are much more than just static presentations.
They’re an essential part of Tableau’s interactivity. In this section, we’ll
populate a dashboard with worksheets and then deploy actions for
interactivity.
Building a dashboard
The following are the steps for building a dashboard:
6. Note the Floating and Tiled buttons at the bottom left, next to your
dashboard, as well as under the handle dropdown. If you select
Floating instead of Tiled, your worksheets will not auto-adjust
anymore and will be “floating” around the dashboard instead. This is
a free form of worksheet arrangement on a dashboard, which is a
powerful functionality, especially combined with transparent
backgrounds. Note that floating can also be achieved by selecting it
from the More Options dropdown on the right-hand side of every
sheet in the dashboard:
7. Now, you can format the dashboard as desired. The following tips
may prove helpful:
As you can see, you have just created your first dashboard. All worksheets
are in place now. In the next part, we will add filter functionality to make
the dashboard more interactive and meaningful.
1. Select the Medals sheet on the dashboard and click on the drop-down
arrow on the right-hand side, which will open a menu as shown in
Figure 1.22. From there, select Filters, then Sport:
Figure 1.22: Adding a filter
2. Now select the newly created filter, Sport, click again on the drop-
down options arrow, and select Multiple Values (dropdown), as well
as Apply to Worksheets | All Using This Data Source, as shown in
Figure 1.23:
Figure 1.23: Filter settings
3. Lastly, place the filter above the Medals sheet by clicking and
dragging it.
4. To use the images of the medals as a filter for the other worksheets on
the dashboard pane, click the Use as Filter icon located at the top-
right corner of the Medals Shapes worksheet:
From here on in, you are good to go and use filters and action filters.
Note
In Tableau, filters are used to subset the underlying data based on certain
conditions, while action filters allow users to interactively filter data by
clicking on a visual element.
Next, you will learn how to connect your own data to Tableau and work
with it.
Although in future chapters we’ll connect to other data sources, here we’ll
limit the discussion to connecting to Microsoft Excel and text files.
Connecting to a file
Let’s see how you can connect to a file, using Excel as an example:
1. In Tableau, navigate to Data | New Data Source | Excel to connect to
the Sample - Superstore dataset that is installed with Tableau
Desktop (it should be located on your hard drive under My Tableau
Repository | Data sources).
2. Double-click on the Orders sheet.
3. Click on the New Worksheet tab, as shown in Figure 1.27:
If you want to connect to a .csv file, you could use the Text file option.
Later in this book, in Chapter 12, Leveraging Advanced Analytics, we will
also connect to spatial files.
Having completed the preceding two exercises, let’s discuss the most
germane point, that is, metadata. Metadata is often defined as data about
data. In the preceding case, the data source name, default aggregation, and
default number formatting are all examples of consistency across multiple
authors.
If you were to change a field name, for example, and then publish the data
source to Tableau Server, the new field name would remain since Tableau
remembers changes made to the metadata. This is important, for example, if
your company has a policy regarding the use of decimal points when
displaying currency; that policy will be easily adhered to if all Tableau
authors start building workbooks by pointing to data sources where all
formatting has been predefined.
Later on in this book, we will connect to other server types, like Google
BigQuery, but the handling of all servers is pretty much the same and very
straightforward. If you still have questions, you can always check out
https://help.tableau.com/current/pro/desktop/en-
us/exampleconnections_overview.htm.
Now, our last missing piece regarding connections is saved data sources.
Please follow along with this as well.
Let’s explore the following steps to create a local data connection using an
example:
You can save a local data source that points to a published data source on
Tableau Server. First, connect to a published data source on Tableau Server.
Then, right-click on the data source in your workspace and choose Add to
Saved Data Sources. Now you can connect to Tableau Server directly from
your start page!
Now that we’ve learned how to connect to files, Tableau Server, and saved
data sources, we will continue our journey and dive into more details
regarding Measure Names and Measure Values.
In this section, we’ll watch what happens when these generated fields are
used independently, then observe how they work elegantly together to
create a view. Let’s explore this with an exercise:
4. Now, drag Measure Names to the Rows shelf and observe that the
view merely displays No Measure Values.
5. Drag Measure Values to the Text shelf. Note the list of measures and
associated values, each of the four values is printed in the respective
row:
Independent of one another, they aren’t of much use. Used together, they
can be applied in many different ways.
Several things happened in step 2 of this exercise. After placing the # Men
number on top of the # Women number in the view, Tableau did the
following:
If the visualization has an axis, the shortcut to deploy Measure Names and
Measure Values requires the placement of a second measure on top of the
axis of an initial measure. In Figure 1.36, Year is located on the Columns
shelf and Number of Records on the Rows shelf. Note that the screenshot
was taken while # Women was placed on top of the y-axis:
Figure 1.36: Axis shortcut
2. Drag Number of Records to the Text on the Marks Card. The result
is mostly meaningless. The number of measures is 15,316, but
without the context supplied by slicing the measure across one or
more dimensions, there is really no way to understand what it means:
Figure 1.38: Worksheet without context
Let’s take a deeper look at the three levels of calculations and consider the
example in the following table:
Calculation
Calculated field in Tableau Query passed to data source
type
FROM Orders
Name the first calculation Lev – Row and enter the following
code: [Number of Records]/[Quantity].
Next, name the second calculation Lev – Agg and enter the
following code: SUM ([Number of Records])/SUM (Quantity).
Lastly, name the third calculation Lev – Tab and enter
WINDOW_AVG ([Lev - Agg]).
4. In the Data pane, right-click on the three calculated fields you just
created and select Default Properties | Number format.
5. In the resulting dialog box, select Percentage and click OK.
6. Place Order Date on the Columns shelf.
7. Place Measure Names on the Rows shelf and Measure Values on
Text on the Marks card.
8. Exclude all values except for Lev - Row, Lev - Agg, and Lev - Tab
by dragging them off the Measure Values shelf or removing them
from the Measure Names filter:
Once again, the results in this case aren’t particularly helpful but do
demonstrate knowledge that a budding Tableau author should possess.
The H2O in River-Left is in a continuous form, that is, water. The H2O in
River-Right is in a discrete form, that is, ice.
Select any field in the Data pane or place any field on a shelf
and you’ll note that it’s either green or blue. Also, the icons
associated with fields are either green or blue.