You are on page 1of 43

ITOM 6212 Data Visualization and Communication

Day 2 – Graphs in Tableau


Exercise 1: Pie Chart
Using the GSS and Bob’s Tableau file you developed in Alteryx, create a Pie Chart in Tableau that shows the Sales
by Ship Mode – make sure to include the Ship Mode and Sales numbers on the pie chart.

The easiest way to do this is to use our Show Me samples. Drag the Ship Mode onto the Color area and drag Sales
into the Detail Area and onto the Size Area. Now click the Pie Chart on the Show Me picture and set the view to
Entire View. Add the Ship Mode and the Sales to the Label area. You can add lines to the chart by clicking on the
Color area and adding a border.

Call this Pie Chart.

Notice we have Null Values because our Coffee Shop data does not ship. We want to remove the null values from
our pie chart.

1
We would like to see just the percentage of the pie instead of the number.

2
If we want to show both the Sales and the % of Sales, we need to do things a little differently. Go back to just sales
and ship mode on the pie chart. Click on SUM(Sales), Quick Table Calculation and then Percentage of Total.

3
Now you can add Sales from Measures to the Label.

4
Exercise 2: Bar Charts and Parameters
Create a Bar Chart with Parameters

a. Using GSS and Bob’s Tableau file you developed in Alteryx, create a Simple Bar Chart using Sales and
Product Name.

5
b. We want to look at our top selling products. Create a Parameter Filter which shows you the top X
products based on sales. Hint: first create an Index which lists the products ranked by sales. Then
create a parameter filter.

Let’s create that Index. We start by Creating a New Field. We will call it “Index”. Just use the Index
Formula by itself.

The Index function works to rank each individual row, based on a certain computation that you define. Drag Index
out onto the view. Note: you may need to change Index to a discrete value. As you drag it to the left of the

6
Product Name, you can see the index goes down in an order from top to bottom of the way the rows are set up
already.

7
In order to get this indexed based on Sales, we need to edit the Index field. Right click on the Index Field and Click
in Edit Table Calculation. Choose Compute Using Specific Dimension. We will choose the Index to be listed
Product Name Sorted by Sum of Sales in Descending order.

8
Once we’ve applied that, now see we have the appropriate rankings there in the index field.

And now we can see the top ten, the top fifteen, or top twenty selling products.
The next thing we want to do is to create a filter for this list that is tied to a parameter. This way, anyone can come
in and just type in a number of the top list they wish to see and this will filter down to exactly that. They can focus

9
just on those products. To do this, we need to create a parameter called “Top N Rank” which will be a range from
1 to 20 and will start with a value of 10.

10
Now we will create a Calculated Field. We will call it “Top Rank Filter”. If the index is less than or equal to the
parameter we created, “Top N Rank”, then bring back just that filter. If the index on the view is less than or equal
to that, then it will return us only that list of rankings.

Then add the Parameter to the Sheet by Right Clicking on Top N Rank and clicking Show Parameter Control.

11
We can see it is set at 10 as we planned. Right now it’s not affecting the view because the last step is to drag that
Top Rank filter out onto the filter shelf, and set it to return only the values where the true condition for that
calculation we just created happens.

12
And then we can see exactly that.

So everywhere where the top ranked products are less than or equal to ten, that will return us the list of the top
ten ranked products.

13
We can also change how we look at this field. Maybe a type-in list would be nicer to see in this case. Click on Top
N Rank and choose “Type In”. Now we can type in the number instead of using a slider.

Now let's color the Bars by Profit so I can see which Products are profitable as well.

14
Change the Color to be Red-Green Diverging

Call this sheet Indexed Products by Sales

15
Since I like the Red-Green Diverging for Profit, I would like to change the default color for Profit. Click on Profit,
Default Properties and Color and Change this to Red/Green Diverging.

16
You can do this for any field.

Exercise 3: Bar Charts and Targets


Create a Bar Chart with Targets

a. Create a Bar Chart which shows Sales by Customer Segment and Customer Name.

17
b. Remove the Null Values from Bob’s Coffee Shop since these are not used as a Sales Target

c. Add a Sales Target Line (Reference Line) for our Customers as a Parameter. Use a sales target range
from 2,000 to 10,000 with a step size of 1,000
Add a reference line. Right Click on the Y Axis, and click on Add Reference Line.

18
Click on the Value field, and create new Parameter. We’ll call this “Customer Sales Target”, and we will
display this again as a range. And we’ll define that range based on the potential sales in this view. Let’s
set a range from 2,000 to 10,000 with a step size of 1,000. Start the value at 3,000.

19
Now Apply This. You can see here now, you can change that sales target, and spot check which of those
bars are meeting the target and which ones aren’t.

20
d. Create a KPI to use on the color shelf, so that those bars will be colored by whether or not they meet
the target we set – Use Green to denote that we met the target and Light Blue that we did not

So, to do that, we can actually create another calculated field based on that sales target. We call this our
“Customer Sales KPI”. Let’s assume that each of those bars that is a sum of sales mark. So if sum of sales
is greater than or equal to that target we’re setting, we’ll say that, in that scenario, that’s GREAT, else if
NOT MEETING TARGET.

Now we can just take that Sales KPI and drop that onto the Color shelf, and just like that, quickly those bars are
labeled different colors for the ones that are not meeting the target goal and the ones not meeting the goal.
Change the color so that Meeting Target is Green and Not Meeting Target are Red. And this is dynamic, so if we
change this, the color of those bars change since it is tied to that parameter, so on and so forth. We’ll call this our
“Customer Sales Target”.

21
22
Call this sheet Customer Sales Target

Exercise 4: Line Charts


Create a Line Chart with Parameters – What would sales look like if they grew by a certain percentage

a. Using GSS and Bob’s Tableau file you developed in Alteryx, create a Line Chart which shows Sales over
time by month.

Sales would be my Rows – Time would be my Columns


Drag Sales to your rows. Now, we want to show order date by Month so right click on order date and
drag it to the columns field and choose Month Order data (from the bottom).

23
Now I can see my Sales by Month.

b. Create a Sales Growth Parameter to see what happens if sales increase by a certain percentage.
i. Create a Parameter called Sales Growth - use Float, and choose a set range between 0 and 1(1%
to 100%) with a step size of .05 (5%). In order to create the sales growth parameter, we need to
create a calculated field.

24
ii. Create a Calculated Field called What if Sales Growth. The formula is Sum (Sales) * (1+(Sales
Growth))

iii. Include the What if Sales Growth on Your Chart (along with Sales)

25
iv. Show the Parameter and adjust it to see if it works

v. Change the Color on the bottom line to Green

26
vi. Use the Dual Axis function to combine both charts together

27
vii. Synchronize your Axes

28
Call this sheet Line Chart

29
Exercise 5: Line Charts and Swapping Fields
a. Create a Line Chart which shows Sales over time on a Quarterly Basis and break down the sales by
Region by showing the Region in Color.

We can use Parameters to SWAP out dimensions on a view to dramatically change the visualization but just by a
simple change of a parameter. Let’s say, I want to see sales over time broken down by category as opposed to
region, or by ship mode. Now, if we knew this were a common choice to jump between for the people we’re
sharing this report with, that makes for a great use case to use a parameter rather than having to recreate the
report with a different field altogether each time.

Let’s start with looking at Sales over time on a quarterly basis. Now, let’s breakdown those sales by region by
showing the region in color.

b. Add a Parameter which allows us to choose which dimension we want to use to view sales by quarter –
we will do this for Region, Category and Ship Mode
a. Create a Parameter called Choose Breakdown – it should be a string list with a list of the 3
Dimensions (Region, Category and Ship Mode)

Now I would like to see sales over time by other dimensions, like Category and Ship Mode– Instead of dragging
each dimension in, I can create a parameter to do that.
With this example, we will create the Parameter first (not the Calculated Field). Let’s create a Parameter called
“Choose Breakdown”.
This will be a simple String List and we will use the different choices of the dimensions we’d like to toggle
between. We will use Region, Category, and Ship Mode. This way we can see sales broken down by all those
different dimensions, by just simply toggling this parameter. So hit OK and see what that looks like.

30
Clear all

Type Region into the Value Field

31
Add Category and Ship Mode

b. Show the Parameter Control

Now Show the Parameter Control.

32
c. Attach this to a Calculated Field – create a calculated field called Choose Color

CASE {Choose Breakdown}

WHEN “Region” THEN Region

WHEN “Category” THEN Product Category

WHEN “Ship Mode” THEN Ship Mode

END

Now we need to attach that to a calculated field, so it affects the view. We will call this “Choose Color”, it’s going
to be dropped onto that Color shelf. To build this, we will use a simple case statement which work very similar to
that if-then logic. So when the input for that parameter returned is Region, then in that case, we want to use the
actual region dimension. When the value returned is Category, then we want the Category field. And finally, when
input chosen is Ship Mode, then want to use the Ship Mode dimension.

33
d. Drop the Choose Color Field on the Color Shelf

Drop the Choose Color field on the Color shelf, and now you see if we change this, the view completely changes to
reflect that breakdown based on that field we choose in the parameter.

34
Call this Swapping Fields

Exercise 6: Area Charts


An area chart or area graph displays graphically quantitative data. It is based on the line chart. The area between
axis and line are commonly emphasized with colors, textures and hatchings. Commonly one compares with an area
chart two or more quantities.

35
a. Create an Area Chart using Sales by Month for each product category (color) – make sure to use the Show
Me for Area Chart

Call this Area Chart

Exercise 7: Points (Square, Circle, Shape)


Use the DV Salary File and create a point chart to show male versus female salary over the years (based on current
dollars). Use the Female Symbol for the female salary and Male Symbol for the Male Salary and color the female
pink and the male blue

We will use Salary over time (Years and Female and Male Current Dollars).

a. First create 2 charts – one for female and one for male. Change the Marks to Shapes and use the Male
shape for Men and Female Shape for Female

36
37
Increase the size and change the color of each (red for Female and Blue for Male – change color by dragging
Female and Male Current Dollars to the Color area)

Make this a dual axis – and synchronize the scale

Call this Salary Points

38
Exercise 8: Scatter Diagrams
Scatter plots provide an easy way to visualize relationships between numerical variables. In Tableau, you create a
scatter plot by placing at least one measure on the columns shelf and at least one measure on the rows shelf. If
these shelves contain both dimensions and measures, Tableau automatically places the measures as the innermost
fields, which means that measures are always to the right of any dimensions you have also placed on these
shelves. The word "innermost" in this case refers to the table structure.

a. Use the GSS and Bob’s Data File


b. Create a scatter diagram using Sales (Columns) and Profit (Rows)

When you plot one number against another, you are comparing two numbers; the resulting chart is
analogous to a Cartesian chart, with x and y coordinates.

What you have at this point is the most basic kind of scatter plot: a one-mark scatter plot.

c. Drag Customer Segment on the Color Mark

This separates the data into four marks—one for each dimension member—and encodes the marks using
color.

d. Drag Customer Name to the Detail Mark.

Call this Scatter Plot

39
Exercise 9: Bubble Charts
A bubble chart is a type of chart that displays three dimensions of data. It is plotted as a disk that expresses two of
the values through the disk's location and the third through its size. Bubble charts can facilitate the understanding
of social, economical, medical, and other scientific relationships.

Bubble charts can be considered a variation of the scatter plot, in which the data points are replaced with bubbles.

Let’s take Segment and Product Category and drop it on Text and Sales on size and click on the Bubble Chart on
Show Me

Let’s color this by Profit

40
Now let’s add Customer Name

This is a Bubble Chart which shows the data by Segment, Category and Customer sized by Sales and colored by
Profit. Call this Bubble Chart.

41
Exercise 10: Heat Map
A heat map is a graphical representation of data where the individual values contained in a matrix are represented
as colors. Fractal maps and tree maps both often use a similar system of color-coding to represent the values
taken by a variable in a hierarchy.

Heat maps are a great way to compare categorical data using color. They are typically constructed as a table using
colored squares to represent the data, and a continuous range of colors. Heat maps allow you to see variations in
the data via variations in color.

In Tableau, you create a heat map by placing one or more dimensions on the column shelf and one or more
dimensions on the row shelf. You then select the mark type as Square and place a measure of interest on the color
shelf.

Let’s create a Heat Map using GSS and Bob’s data.

Use the Customer Segment on the columns shelf and Region and Category on the Rows shelf. Place profit on the
color shelf. Select the Marks to be Square. Exclude Nulls.

42
Call this Heat Map.

43

You might also like