Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Table of Contents

Preface

Reviewing the Basics

Getting Your Data Ready

Using Tableau Prep Builder

Learning about Joins, Blends, and Data Structures

Introducing Table Calculations

Utilizing OData, Data Densification, Big Data, and Google BigQuery

Practicing Level of Detail Calculations

Going Beyond the Basics

Working with Maps

Presenting with Tableau

Designing Dashboards and Best Practices for Visualizations

Leveraging Advanced Analytics

Improving Performance

Exploring Tableau Server and Tableau Cloud

Integrating Programming Languages

Developing Data Governance Practices

Other Books You May Enjoy


Index
Preface
This edition of the bestselling Tableau guide will teach you how to leverage
Tableau’s newest features and offerings in various paradigms of the BI
domain. Updated with fresh topics including the newest features in Tableau
Server, Prep, and Desktop, as well as up-to-date examples and solutions to
real-world challenges, this book will take you from mastering essential
Tableau concepts to advanced functionalities. A new chapter on data
governance has also been added.

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 2, Getting Your Data Ready, is a theory-oriented chapter that will


help you understand data preparation and henceforth work more easily with
messy data.

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 5, Introducing Table Calculations, covers the special case of table


calculations, which use the data order to assign values like ranks.

Chapter 6, Utilizing OData, Data Densification, Big Data, and Google


BigQuery, teaches you how to leverage big data solutions and the concept
of data densification.

Chapter 7, Practicing Level of Detail Calculations, helps you understand


this advanced topic, which can change the aggregation of your data for
certain calculations.

Chapter 8, Going Beyond the Basics, introduces you to advanced


visualization concepts and Tableau Exchange, Extensions, Accelerators, and
Connectors.

Chapter 9, Working with Maps, covers Tableau’s internal, and some


external, mapping capabilities using custom polygons, heatmaps, and
layered maps.

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 13, Improving Performance, addresses various aspects of


performance with the intent to empower you to create fast-loading
dashboards for the best user experience.

Chapter 14, Exploring Tableau Server and Tableau Cloud, covers the
different offerings and functionalities of Tableau Server, including Ask Data
and Data Details.

Chapter 15, Integrating Programming Languages, shows you how to


integrate R and Python with Tableau to enable (almost) unlimited analytics
capabilities.

Chapter 16, Developing Data Governance Practices, introduces you to the


vast and important topic of data governance and how to comply with
regulations by using Tableau Server.

To get the most out of this book


Basic knowledge of Tableau will be an advantage and you will need a
Tableau license after your 14-day free trial ends. You will also benefit from
basic knowledge of R or Python if you wish to get the most out of Chapter
15, Integrating Programming Languages. You can, however, also follow
along with the steps and learn as you go.

Other helpful installations will be mentioned in the book as needed, all in


the realm of the average free-ware installation on Windows or Mac.

Download the example code files


The code bundle for the book is also hosted on GitHub at
https://github.com/PacktPublishing/Mastering-Tableau-2023-Fourth-
Edition. We also have other code bundles from our rich catalog of books
and videos available at https://github.com/PacktPublishing/. Check them
out!

Download the color images


We also provide a PDF file that has color images of the
screenshots/diagrams used in this book. You can download it here:
https://packt.link/TybKH.

Conventions used
There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder


names, filenames, file extensions, pathnames, dummy URLs, user input,
and Twitter handles. For example: “When recording performance, Tableau
initially creates a file in My Tableau Repository\Logs, named
performance_[timestamp].tab.”

A block of code is set as follows:

SCRIPT_REAL("x <- lm(.arg1 ~ .arg2 + .arg3 + .arg4)


x$fitted", SUM(Profit), COUNT(Quantity), SUM(Sales),
AVG(Discount)
)

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.

General feedback: Email [email protected], and mention the


book’s title in the subject of your message. If you have questions about any
aspect of this book, please email us at [email protected].

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.

If you are interested in becoming an author: If there is a topic that you


have expertise in and you are interested in either writing or contributing to a
book, please visit http://authors.packtpub.com.

Share your thoughts


Once you’ve read Mastering Tableau 2023 - Fourth Edition, we’d love to
hear your thoughts! Please click here to go straight to the Amazon review
page for this book and share your feedback.
Your review is important to us and the tech community and will help us
make sure we’re delivering excellent quality content.

Download a free PDF copy of this


book
Thanks for purchasing this book!

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

Follow these simple steps to get the benefits:

1. Scan the QR code or visit the link below


https://packt.link/free-ebook/9781803233765

2. Submit your proof of purchase


3. That’s it! We’ll send your free PDF and other benefits to your email
directly
Reviewing the Basics
Tableau is one of the leading tools used to solve business intelligence (BI)
and analytics challenges. With this book, you will master Tableau’s features
and offerings in various paradigms of the BI domain. As an update to the
successful Mastering Tableau series, this book covers the essential Tableau
concepts, data preparation, and calculations with Tableau, all the way up to
machine learning use cases.

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.

In this chapter, we’ll discuss the following topics:

Creating worksheets and dashboards


Connecting Tableau to your data
Measure Names and Measure Values
Three essential Tableau concepts
Exporting data to other devices

Now, let’s get started by exploring worksheet and dashboard creation in


Tableau.

Creating worksheets and


dashboards
At the heart of Tableau are worksheets and dashboards. Worksheets
contain individual visualizations and dashboards contain one or more
worksheets. Additionally, worksheets and dashboards may be combined
into stories to communicate particular insights to the end user through a
presentation environment. Lastly, all worksheets, dashboards, and stories
are organized in workbooks, which can be accessed using Tableau
Desktop, Server, Reader, or the Tableau mobile app.

At this point, I would like to introduce you to Tableau Public


(https://public.tableau.com/app/discover). At times, you might need some
inspiration, or you might want to replicate a dashboard created by another
Tableau user. In this case, Tableau Public will be your place to go! It is a
web-based collection of dashboards, as well as a creator’s platform that
allows you to design beautiful dashboards without a license or installation.

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.

In this section, we’ll consider how to create worksheets and dashboards.


Our intention here is to communicate the basics, but we’ll also provide
some insight that may prove helpful to more seasoned Tableau users.

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:

Figure 1.1: 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:

Figure 1.2: Navigating worksheet tabs

4. The dashboard is connected to two data sources; for this first


exercise, we will use the Summer-Olympics data. Click on the data
source Summer-Olympics in the top-left corner:

Figure 1.3: Data source

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

7. Click on Color on the Marks card and then on Edit Colors… to


adjust the colors of your visualization as desired. This will allow you
to edit the colors used in your visualization, and Transparency and
Border effects:

Figure 1.6: Edit Colors…


8. Now see what happens if you move Sport to the Size, Label, Detail,
Columns, and Rows shelves. After placing Sport on each shelf, you
can click on each shelf individually to access additional options.
9. Drop other fields on various shelves to continue exploring Tableau’s
behavior. One example could be, on an empty canvas, dragging Year
to the Columns shelf, Number of Records to the Rows shelf, and
Medal to Color on the Marks card. You will now see the number of
medals per medal type over time:

Figure 1.7: Medals over time

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!

As you explore Tableau’s behavior by dragging and dropping different


fields onto different shelves, you’ll notice that Tableau responds with
default behaviors. These defaults, however, can be overridden, which we’ll
explore next.

Beyond the default behavior


In the preceding exercise, Creating a visualization, we can notice that the
Marks card reads Automatic. This means that Tableau is providing the
default view. The default view can easily be overridden by choosing a
different selection from the drop-down menu:

Figure 1.8: The Marks card drop-down menu


By changing these settings on the Marks card, we can adjust the format in
which your data will be displayed.

Another type of default behavior can be observed when dragging a field


onto a shelf. For example, dragging and dropping a measure onto a shelf
will typically result in the SUM() aggregation, which will sum up all the
values to the highest level of aggregation. If no dimension is present, it will
be the sum of all values. If a dimension is present on the Marks card, this
same dimension will serve as the highest level of aggregation.

We will see an example of this behavior later in this section.

In Windows, you can override this default behavior by right-clicking and


dragging a pill from the Data pane and dropping it onto a shelf. Tableau
will respond with a dialog box with possible options:

Figure 1.9: Changing the default aggregation

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:

1. In the workbook associated with this chapter, navigate to the


Overriding Defaults worksheet.
2. Drag and drop Year from the data pane to the Columns shelf:

Figure 1.10: Year to Columns

3. Place Number of Records on the Rows shelf (which is automatically


aggregated to SUM(Number of Records)) and Sport on the Detail
shelf.
4. Click on the dropdown on the Marks card and select Area:
Figure 1.11: Area chart

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.

Sorting and nested sorting


Now that you are familiar with the basics of dragging and dropping pills
and are aware of Tableau’s default behavior, the next thing most users want
to do is to sort the data to draw first conclusions, regarding, for example,
minimum and maximum values.

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.

Did it work for you?

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…:

Figure 1.13: Sort settings


From the dropdown, select Nested and the desired Field Name, as well as
the Aggregation type:

Figure 1.14: Nested 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:

Figure 1.15: Show Me

Now let’s look at the following aspects that are highlighted in the preceding
screenshot:

A: Selected fields in the Data pane


B: Fields deployed in the view, that is, pills
C: The recommended view, highlighted in the Show Me panel
D: Help text that communicates the requirements for creating the
recommended view or any selection choice over which the cursor is
placed

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.

Show Me may be effectively used for the following reasons:

Efficiency: A proficient Tableau author already knows how to create


the basic visualization types. Show Me automates these basic types and
thus may be used for quicker production.
Inspiration: Determining an effective way to visualize a dataset can
be challenging. Show Me can help with this challenge by allowing the
Tableau author to quickly consider various options.
Education: An inexperienced Tableau author may access Show Me to
better understand how various visualizations are created. By reading the
help text displayed at the bottom of Show Me and changing the pill
placement accordingly, much can be learned:
Figure 1.16: Show Me

These three reasons demonstrate the strong capabilities that Show Me


provides for worksheet creation; however, be careful not to use it as a
crutch. If you click on the various options without understanding how each
visualization is created, you’re not only shortchanging the educational
process but you may also generate results that you don’t understand and
hence cannot explain to your stakeholders.
Once you are happy with the results and confident that the selected
visualization puts enough emphasis on your data storytelling, your
worksheet is ready for the next round of development. We’ve looked at
some basic visualization creation and configuration techniques, so let’s now
look at how to group multiple worksheets into a dashboard.
Note
Data storytelling is the art of using data to create a compelling story
through visualizations such as graphs and charts. It combines the power
of data analytics with storytelling techniques to convey complex
information in an engaging and understandable way.

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.

Let’s begin by building a dashboard.

Building a dashboard
The following are the steps for building a dashboard:

1. In the workbook for this chapter, navigate to the Building a


Dashboard tab.
2. In the Dashboard pane, located on the left side of the Figure 1.17,
double-click on each of the following worksheets (in the order in
which they are listed) to add them to the dashboard pane: Count of
Disciplines, Attendees, Medals, and Medal Shapes:
Figure 1.17: Creating a dashboard

3. In the bottom-right corner of the dashboard, click in the blank area


(indicated by an arrow in Figure 1.18) to select a container.
Containers are a selection of sheets that auto-adjust to fit next
to/underneath each other on your dashboard:

Figure 1.18: Deleting a container


4. After clicking in the blank area, you should see a blue border around
the filter and the legends. This indicates that the vertical container is
selected. Select the vertical container handle and delete it by clicking
the X.
5. A selected container can also be dragged to a different location on the
dashboard, replacing an existing sheet or sharing space. Note the gray
shading in Figure 1.19, which communicates where the selection will
be placed. Drag the Attendees worksheet by selecting and holding
the handle and put it on top of the Count of Disciplines worksheet in
order to swap the two:

Figure 1.19: Moving worksheets

The gray shading provided by Tableau when dragging elements, such


as worksheets and containers, onto a dashboard helpfully
communicates where the elements will be placed. Take your time and
observe carefully when placing an element on a dashboard or the
results may be unexpected.

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:

Figure 1.20: Tiled and Floating

7. Now, you can format the dashboard as desired. The following tips
may prove helpful:

Adjust the sizes of the elements on the screen by hovering over


the edges between each element and then clicking and dragging.
Drag the edges of containers to adjust the size of each worksheet.
Make an element floating, as shown in Figure 1.18.
Create horizontal and vertical containers by dragging
Horizontal and Vertical from the Objects pane onto the
dashboard. Other objects, such as Text, Image, and Blank, can be
added to containers too.
Display the dashboard title by selecting Dashboard in the top
pane, then Show Title. Double-click the title itself to adjust:
Figure 1.21: The Olympics dashboard

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.

Adding interactivity to a dashboard


One of the primary benefits of Tableau is the interactivity it provides for the
end user. Dashboards aren’t simply for viewing; they’re meant for
interaction. In this exercise, we’ll add interactivity to the dashboard that
was created in the previous exercise:

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:

Figure 1.24: The Use as Filter option


5. Alternatively, navigate to Dashboard | Actions…. In the dialog box,
click Add Action | Filter and create a filter, as shown:

Figure 1.25: Navigating to filters


Figure 1.26: Adding a filter action

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.

In Chapter 13, Improving Performance, this topic will be discussed in more


detail.

Having completed the preceding dashboard exercise, you should now be


able to click on various objects on the dashboard to observe the
interactivity.

To learn some more advanced dashboard techniques, be sure to check out


Chapter 11, Designing Dashboards and Best Practices for Visualizations.
To conclude, you have learned how to put existing worksheets, as tiled or
floating objects, on a dashboard. You have changed the dashboard layout by
dragging and dropping, as well as by using containers, filters, and action
filters. Each of these core activities will be repeated multiple times
throughout the book, so feel free to come back to this chapter and repeat the
exercise steps whenever needed!

Next, you will learn how to connect your own data to Tableau and work
with it.

Connecting Tableau to your data


At the time of writing, Tableau’s data connection menu includes more than
90 different connection types. And that’s somewhat of an understatement
since some of those types contain multiple options. For example, Other
Files includes more than 30 options. Of course, we won’t cover the details
for every connection type, but we will cover the basics. The official
documentation on all connectors can be found here:
https://help.tableau.com/current/pro/desktop/en-
us/exampleconnections_overview.htm.

Upon opening a new instance of Tableau Desktop from within Tableau


Desktop (File | New), you’ll notice a Connect to Data link in the top-left
corner of the workspace. Clicking on that link will enable you to connect to
the data. Opening a new instance of Tableau from the application’s location
on your computer will bring up the blue Connect pane right away.
Alternatively, you can click on the New Data Source icon on the toolbar.

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:

Figure 1.27: New worksheet

4. Rename the newly created tab to First Worksheet by right-clicking


and selecting Rename.
5. Place Discount on the Text shelf in the Marks card.
6. Double-click on Profit and Sales:

Figure 1.28: First worksheet

You’ve just created your first worksheet!

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.

In this section, we learned how to connect to files. We’ll continue with


another important connection type in the next section: Tableau Server.

Connecting to Tableau Server


Connecting to Tableau Server is perhaps the single most important server
connection type to consider, since it’s frequently used to provide a better
level of performance than may otherwise be possible. Additionally,
connecting to Tableau Server enables the author to receive not only data but
also information regarding how that data is to be interpreted—for example,
whether a given field should be considered a measure or a dimension.
We’ll discuss the difference between these terms in the Dimensions and
measures section later in the chapter.

The following are the steps for connecting to Tableau Server:

1. To complete this exercise, access to an instance of Tableau Server is


necessary. If you don’t have access to Tableau Server, consider
installing a trial version on your local computer.
2. In the workbook associated with this chapter, navigate to the
Connecting to Tableau Server worksheet.
3. Right-click on the Superstore data source and select Publish to
Server…:
Figure 1.29: Publish to Server…

4. Log in to Tableau Server and follow the prompts to complete the


publication of the data source.
5. Open a new instance of Tableau Desktop, select Data | New Data
Source | Tableau Server, and then search for the Superstore dataset
you just published and connect.

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.

Connecting to saved data sources


Connecting to a saved data source on a local machine is very similar to
connecting to a data source published on Tableau Server. Metadata
definitions associated with the local data source are preserved just as they
are on Tableau Server. Of course, since the data source is local instead of
remote, the publication process is different.

Let’s explore the following steps to create a local data connection using an
example:

1. In the workbook associated with this chapter, navigate to the First


Worksheet tab.
2. In the Data pane, right-click on the Superstore data source and
select Add to Saved Data Sources.
3. Using the resulting dialog box, save the data source as Superstore in
My Tableau Repository | Data sources, which is located on your
hard drive.
4. Click on the Go to Start icon located in the top-left part of your
screen and observe the newly saved data source:

Figure 1.30: Saved Data Sources

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.

Measure Names and Measure


Values
I’ve observed the following scenario frequently: a new Tableau author
creates a worksheet and drags a measure to the Text shelf. They drag the
second measure to various places on the view and get results that seem
entirely unpredictable. The experience is very frustrating for the author
since it’s so easy to accomplish this in Microsoft Excel! The good news is
that it’s also easy to accomplish this in Tableau. It just requires a different
approach.

Measure Names and Measure Values are generated fields in Tableau.


They don’t exist in the underlying data, but they’re indispensable for
creating many kinds of views. As may be guessed from its placement in the
Data pane and its name, Measure Names is a dimension whose members
are made up of the names of each measure in the underlying dataset.
Measure Values contains the numbers or values of each measure in the
dataset.

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:

1. In the workbook associated with this chapter, navigate to the


MeasureNames/Values and make sure that the Olympics data source
is selected.
2. Drag Measure Values to the Text shelf and observe the results, all
four values are printed on top of each other:
Figure 1.31: Measure Values

3. Clear the worksheet by clicking on the Clear Sheet icon on the


toolbar:

Figure 1.32: Clear Sheet

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:

Figure 1.33: List of Measure Values

Perhaps the relationship between Measure Names and Measure Values is


best explained by an analogy. Consider several pairs of socks and a
partitioned sock drawer. Step 2 is the equivalent of throwing the socks into
a pile. The results are, well, disorganized. Step 4 is the equivalent of an
empty sock drawer with partitions. The partitions are all in place but where
are the socks? Step 5 is a partitioned drawer full of nicely organized socks.
Measure Names is like the sock drawer. Measure Values is like the socks.

Independent of one another, they aren’t of much use. Used together, they
can be applied in many different ways.

Measure Names and Measure Values


shortcuts
Tableau provides various shortcuts to quickly create the desired
visualization. If you’re new to the software, this shortcut behavior may not
seem intuitive, but you’ll gain an understanding of it. Let’s use the
following exercise to explore how you can use a shortcut to rapidly deploy
Measure Names and Measure Values:

1. In the workbook associated with this chapter, navigate to the


MeasureNames/Values ShrtCts worksheet.
2. Drag # Women onto Text in the Marks card.
3. Drag # Men directly on top of # Women in the view (Show Me
appears):
Figure 1.34: Show Me and Measures

4. Observe the results, including the appearance of the Measure Values


shelf, the deployment of Measure Names on the Rows and Filters
shelves, and Measure Values on the Text shelf:

Figure 1.35: Measure Values appearance

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:

1. Deployed Measure Names on the Filters shelf:


Open the Measure Names filter by right-clicking and hit Edit
Filter... Observe that only # Men and # Women are selected. This
limits the view to display only those two measures.

2. Deployed Measure Names on the Rows shelf:

Measure Names is acting like a partitioned container, that is, like


the sock drawer in the analogy. Because of the filter, the only
rows that display are for # Men and # Women.

3. Displayed the Measure Values shelf:

The Measure Values shelf is somewhat redundant. Although it


clearly shows the measures that are displayed in the view, it
essentially acts as an easy way to access the filter. You can simply
drag measures on and off of the Measure Values shelf to adjust
the filter and thus display/hide additional Measure Values. You
can also change the order within the Measure Values shelf to
change the order of the measures in the view.

4. Deployed Measure Values on the Text shelf:

Measure Values is simply defining the numbers that will


display for each row—in this case, the numbers associated with #
Men and # Women.

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

The resulting worksheet can be seen in Figure 1.37:


Figure 1.37: Two-line chart

The preceding section gave us a better understanding of Measure Names


and Measure Values. You will come across those concepts more in your
Tableau career, but now that you’ve successfully mastered the basics, let’s
move on to three other concepts that will be beneficial for your learning
curve.

Three essential Tableau concepts


An important stop on the road to mastering Tableau involves three essential
concepts. In this section, we’ll discuss each of them:
Dimensions and measures
Row-level, aggregate-level, and table-level calculations
Continuous and discrete

We’ll start by defining dimensions and measures.

Dimensions and measures


Tableau categorizes every field from an underlying data source as either a
dimension or a measure. A dimension is qualitative or, to use another
word, categorical. A measure is quantitative or aggregable. A measure is
usually a number but may be an aggregated, non-numeric field, such as MAX
(Date). A dimension is usually a text, Boolean, or date field, but may also
be a number, such as Number of Records. Dimensions provide meaning to
numbers by slicing those numbers into separate parts/categories. Measures
without dimensions are mostly meaningless.

Let’s look at an example to understand better:

1. In the workbook associated with this chapter, navigate to the


Dimensions and Measures worksheet.

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

3. Place Country and Year on the Columns shelf and Number of


Records on the Rows shelf:
Figure 1.39: Dimensions and Measures

As shown in Figure 1.39, step 3 brings meaning. Placing Country and


Year on the Columns shelf provides context, which imparts meaning to the
visualization.

Row-level, aggregate-level, and table-


level calculations
There are three levels of calculations in Tableau: row, aggregate, and table.
To understand how these three levels function, it’s important to understand
the Tableau processes. We’ll do so with an example that considers the
Number of Records and Quantity fields from the Superstore dataset.

Consider the following calculation types, calculated fields, and queries. A


comparison to the commonly used language SQL will give us a better
understanding of how to interpret Tableau calculations. Note that the SQL is
slightly simplified for the sake of this example.

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

SELECT Number of Records /

Row-level Number of Records/Quantity Quantity)

FROM Orders

Aggregate- SELECT [Number of Records]),


[Number of Records])/Sum(Quantity)
level SUM(Quantity) FROM [Orders]

WINDOW_Sum([Number of SELECT [Number of Records]),


Table level
Records])/Quantity)) SUM(Quantity) FROM [Orders]

For the row- and aggregate-level calculations, the computation is actually


completed by the data source engine, as Tableau is an in-memory tool.
Tableau merely displays the results. This, however, isn’t the case for the
table-level calculation. Although the query passed to the data source for the
table-level calculation is identical to the query for the aggregate-level
calculation, Tableau performs additional computations on the returned
results. Let’s explore this further with an exercise using the same calculated
fields.

Let’s look at the following steps and begin our exercise:

1. In the workbook associated with this chapter, navigate to the


Row_Agg_Tbl worksheet.
2. Connect to the Superstore data source by clicking on Sample -
Superstore in the Data section in the top-left corner.

Figure 1.40: Connect to Superstore

3. Select Analysis | Create Calculated Field to create the following


calculated fields. Note that each must be created separately; that is, it
isn’t possible in this context to create a single calculated field that
contains all three calculations:

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:

Figure 1.41: Level of calculations

Lev - Agg is an aggregate-level calculation. The computation is


completed by the data source engine. The sum of [Number of Records]
is divided by the sum of [Quantity]. The results of the calculation are
likely useful for the Tableau author.
Lev - Row is a row-level calculation. The computation is completed
by the data source engine. [Number of Records] is divided by
[Quantity] for each row of the underlying data. The results are then
summed across all rows. Of course, in this case, the row-level
calculation doesn’t provide useful results; however, since a new Tableau
author may mistakenly create a row-level calculation when an
aggregate-level calculation is what’s really needed, the example is
included here.
Lev - Tab is a table calculation. Some of the computation is completed
by the data source engine, that is, the aggregation. Tableau completes
additional computation on the results returned from the data source
engine based on the dimensions and level of detail in the data displayed
in the sheet. Specifically, the results of Lev - Agg are summed and then
divided by the number of members in the dimension. For the preceding
example, this is:

Once again, the results in this case aren’t particularly helpful but do
demonstrate knowledge that a budding Tableau author should possess.

Continuous and discrete


Continuous and discrete aren’t concepts that are unique to Tableau. Indeed,
both can be observed in many arenas. Consider the following example:
Figure 1.42: Continuous and discrete

The preceding diagram is of two rivers: River-Left and River-Right. Water is


flowing in River-Left. River-Right is composed of ice cubes. Could you
theoretically sort the ice cubes in River-Right? Yes! Is there any way to sort
the water in River-Left? In other words, could you take buckets of water
from the bottom of the river, cart those buckets upstream and pour the water
back into River-Left, and thereby say “I have sorted the water in the river?”
No.

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.

Having considered continuous and discrete examples in nature, let’s turn


our attention back to Tableau. Continuous and discrete in Tableau can be
more clearly understood with the following seven considerations:

1. Continuous is green. Discrete is blue:

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.

2. Continuous is always numeric. Discrete may be a string.


3. Continuous and discrete aren’t synonymous with dimensions and
measures:

It’s common for new Tableau authors to conflate continuous


with measures and discrete with dimensions. They aren’t
synonymous. A measure may be either discrete or continuous.
Also, a dimension, if it’s a number, may be discrete or
continuous. To prove this point, right-click on any numeric or
date field in Tableau and note that you can convert it:

Figure 1.43: Converting between discrete and continuous

4. Discrete values can be sorted. Continuous values can’t:

You might also like