Chapter 1. Bar Charts

1.0 Introduction

Bar charts are one of the most commonly used chart types. It allows the human eye to compare differences between length or height. A bar chart is split by categorical data and show a continuous measure. There are two types of basic bar charts. A vertical bar and a horizontal bar. There are other variations of bar chart which include stacked bar charts, histograms and marimekko charts.

1.1 Horizontal Bar Chart

Problem

You need to create a horizontal bar chart which shows, high to low, the sum of sales by sub-category.

Solution

Option 1:

  1. Start by creating a new sheet.

  2. Using the Superstore sales data, double click sub-category:

2 1 horizontal bar chart 123612 01
  1. Then drag sales to columns:

2 1 horizontal bar chart 123612 02
  1. If you hover over the axis, you will get a sorted bar icon. Click this and you will end up with a descending bar chart:

2 1 horizontal bar chart 123612 03

Option 2: 1. Create a new sheet. 2. Double click sales (1). Double click sub-category (2). This creates the Vertical Bar Chart:

2 1 horizontal bar chart 123612 04
  1. To convert this to a horizontal bar chart use the swap rows and columns button (1) in the toolbar. Then click the sort descending button in the toolbar (2).

2 1 horizontal bar chart 123612 05

Option 3:

  1. Select click sales.

  2. Hold control (command on Mac) and select Sub-Category.

  3. On the right, there is an option called Show Me. Click that tab.

  4. Click the chart that Tableau highlights best suited for the selections. This is shown by having an orange border:

    2 1 horizontal bar chart 123612 06
  5. Another way to sort the data is by right-clicking the Sub-Category pill in rows and click sort:

    2 1 horizontal bar chart 123612 07
  6. Change to by Field:

    2 1 horizontal bar chart 123612 08
  7. Change to Descending and confirm it is by sales and the aggregation is Sum:

    2 1 horizontal bar chart 123612 09

Discussion

In the solution provided, a horizontal bar suits the data more effectively. If you look at Option 2 where Tableau defaulted to building a vertical bar chart, you can see the Sub-Category headers are rotated vertically, meaning the reader would have to tilt their head to read the headers. With a horizontal bar, this allows the Sub-Category header to have more space and allow the reader to not have to shift position to read, therefore allowing faster reading of this chart type. Vertical bar charts have their use cases too, see histogram (2.5).

1.2 Adding a constant line

Bar charts are great for visualizing the length of a value, but they are also great in comparing whether a Sub-Category is above or below a constant line. A constant line is a static reference line which allows you to enter a single value of reference.

Problem

You need to have a reference line on your bar chart, to visually see where a constant value is compared to the sales of the sub-categories.

Solution

  1. Continuing with one of your bar charts click the analytics pane:

    2 1 horizontal bar chart 123612 10
  2. Click, hold, and drag the constant line to the view:

    2 1 horizontal bar chart 123612 11
  3. The value box will automatically appear. Enter 100,000:

    2 1 horizontal bar chart 123612 12

Discussion

A constant line is used for charts when you know you have a specific target or reference point. For example, each Sub-Category has a target of 100,000 sales. The next section shows you how to input a number to control the constant line.

1.3 Changing to a user controlled reference line

In recipe 2.1.1, it showed you how to add a constant reference line. A user controlled reference line will allow the user to change the value of the reference line using a parameter.

Problem

You need to change the constant number in the reference line on your bar chart, because the sales value will change when you add new data, this control allows you to change the reference line to suit.

Solution

  1. Continuing with one of your bar charts with the constant line (2.1.1).

  2. Right-click on the axis and select edit reference line:

    2 1 horizontal bar chart 123612 13
  3. Click the drop down option (1) and change the type to Sum (2):

    2 1 horizontal bar chart 123612 14
  4. Then click on the Value box and change it to create a new parameter:

    2 1 horizontal bar chart 123612 15
  5. Rename the parameter and change current value to 150000, then Click Ok:

    2 1 horizontal bar chart 123612 16
  6. Customize the reference line by changing the label drop-down to Value, then click Ok.

    2 1 horizontal bar chart 123612 17
  7. When you add a new parameter via a reference line, tableau automatically shows reference line card (1). Whenever you change the parameter, it will move the reference line.

    2 1 horizontal bar chart 123612 18

Discussion

Like the constant line, this allows the user to input different values to visually see which sub-categories are above and below that reference line.

1.4 Adding Color to a controlled reference line

Problem

You need to visually see whether the bar chart is above or below the controlled reference line on your bar chart. You can do this by using colour.

Solution

  1. Duplicating the previous sheet with the controlled reference line.

  2. Create a Calculated field and input a boolean calculation which says SUM([Sales])>=[Reference Line Parameter]:

    2 1 horizontal bar chart 123612 19
  3. You will need to add this calculation to Colour:

    2 1 horizontal bar chart 123612 20

Discussion

Using colour allows the user to quickly see which sub-categories are above or below the line. Tableau’s automatic colours for this type of boolean calculation are Orange and Blue, because they are the first two colours in the Tableau’s default colour palette. Colour choice is very important in data visualisation because some of your audience could be colour blind. Making sure your colours are colour-blind friendly is important as they might only be able to see shades of colours depending on what type of colour-blind they are.

1.5 Adding Average Lines

Constant lines and controlled constant lines are needed for user input, but what if you want to show the average per category?

Problem

You want to see a reference line for the average sales per category.

Solution

  1. Start with double clicking sales and category from the order table on the left.

    2 1 horizontal bar chart 123612 21
  2. Click the plus button on the Category pill to drill down to Sub-Category:

    2 1 horizontal bar chart 123612 22
  3. Drag sales to columns and sort descending by clicking on the axis (See recipe 2.1):

    2 1 horizontal bar chart 123612 23
  4. On the analytics pane, hold and drag Average Line to the view. There are three options for the reference line, which are discussed in the discussion but the pane option depends on what dimensions are in the view. If you want to get an average by Category but you have sub-category in the view you will need to choose pane option. This will give an average of the total Sum of sales per Category:

    2 1 horizontal bar chart 123612 24

Discussion

Average lines are good if you have multiple levels of detail in your view. There are three options for average lines. Table, Pane and Cell. Pane is mentioned in the solution

2 1 horizontal bar chart 123612 25

Table would give you the average of all sub-categories not split by category.

2 1 horizontal bar chart 123612 26

The Cell option would require a different level of detail. If you add [Order ID] to detail and change the marks card to circle. Then add a cell average line. This will give you the average total sales per order in each sub-category.

2 1 horizontal bar chart 123612 27

1.6 Grouping

Grouping in Tableau can be used as simple data preparation. Whether you are grouping based on incorrect spellings or grouping people into teams. Groups are a manual process because they are based on the data that you have. If you have clean data or have used data preparation you might not need to create manual groups.

Problem

You need to manually group your data so that you can compare manual product groups

Solution

  1. Right Click on Product Name, go to Create, then Group:

    2 1 horizontal bar chart 123612 28
  2. This allows you to manually create the groups.

  3. Rename the group by editing the Field Name at the top. “A-D Products Group.”

  4. Click the first product, hit shift, and scroll down to the last product beginning with D. Then click Group:

    2 1 horizontal bar chart 123612 29
  5. Whilst still highlighted rename group to “A-D Products”:

    2 1 horizontal bar chart 123612 30
  6. You can repeat this many times.

  7. If you tick “Include ‘Other’” this will group all the other products into a group called other. You might want to group things under other because in this example it would keep all the individual products, using this option allows us to compare against all the other products:

    2 1 horizontal bar chart 123612 31
  8. Once you have added all your groups, click ok.

  9. Find the group in the left pane and double click it. Then drag Sales onto Columns:

    2 1 horizontal bar chart 123612 32

Discussion

Manual grouping is a fundamental part of Tableau and is not dynamic, which means if you have new products beginning with A-D then you would have to manually add them to your view. There are a few different ways of grouping your data which depend on how you want to group your data. They are Visual grouping (2.1.5.1), Discrete grouping (2.1.5.2) and Conditional grouping (2.1.5.3).

1.7 Visual Grouping

Problem

You want to visually group dimensions to highlight members in the group.

Solution

  1. Create a horizontal bar chart with Product Name and Sum of Sales, sorted descending.

  2. On the bars, click and drag to highlight the top 10:

    2 1 horizontal bar chart 123612 33
  3. Hover over a highlighted bar and select the Paper Clip:

    2 1 horizontal bar chart 123612 34
  4. This creates a new group with those selected product names and automatically adds it to colour:

    2 1 horizontal bar chart 123612 35

Discussion

This is a good way to group dimensions, to see where the members in the group visually lie. Especially as tableau automatically puts this group onto Colour. Again, this group is NOT dynamic. As previously mentioned, these types of grouping are a manual process, meaning if the top 10 products change, you would have to repeat the steps mentioned.

1.8 Discrete Grouping

Problem

I want to group similar products together.

Solution

  1. Create a horizontal bar chart with Product Name and Sum of Sales.

  2. Hover over the start of the bar until you get a sideways arrow. Drag right until you can see the full product name for 3D Systems Cube Printer:

    2 1 horizontal bar chart 123612 36
  3. Press Control (Command on Mac), select both of the 3D Systems Cube Printers. Click the paper clip to group:

    2 1 horizontal bar chart 123612 37
  4. Notice how this groups those two products into one bar and doesn’t add the group to colour:

    2 1 horizontal bar chart 123612 38

Discussion

This type of grouping is good for spelling mistakes or to combine dimensional fields.

1.9 Conditional Grouping

Problem

I want to see three groups based on whether the profit of a sub-category is above 25000, above 0 and below 0, which can be formed using a conditional IF statement.

Solution

  1. Create a horizontal bar chart using Sub-Category and Sum of Profit, sort descending by Sum of Profit (recipe 2.1).

  2. Open a new calculated field and use the following IF statement (more on this in the Discussion). The values can be changed to suit. Click OK:

    2 1 horizontal bar chart 123612 39
  3. Drag the Conditional Profit Grouping calculation to the Colour Marks Card:

    2 1 horizontal bar chart 123612 40
  4. This will split the Sub-Categories into their respective conditional categories based on the IF statement you created in step 2:

    2 1 horizontal bar chart 123612 41

Discussion

This type of grouping is good if you have constant targets. You can create as many or as little conditional groups as you like. A simple IF statement works with the following logic: “IF this THEN that ELSE the other END."”

The ELSE allows a group for everything that doesn’t follow the condition.

2 1 horizontal bar chart 123612 42

If you need three or more conditions you should add an ELSEIF before the ELSE. You can have many ELSEIF’s on a conditional statement.

2 1 horizontal bar chart 123612 43

When using an IF statement, you need to always finish the statement with an END. Should you need another example of a Conditional statement, Tableau has an example built into the calculation window. Click the right arrow to expand the calculation window.

2 1 horizontal bar chart 123612 44

In the search box under the ‘All’ drop down and type IF, click the third one down to get the example and description:

2 1 horizontal bar chart 123612 45

1.10 Top N Filter

Filters, as mentioned in Chapter 1, are useful for showing a subset of the data. A Top N filter allows you to show a subset of data based on a measure. This can be used due to lack of space in the visualisation or because you want to focus on this top N.

Problem

I only want to see the Top N number of customers by the sum of sales.

Solution

  1. Create a horizontal bar chart using Customer Name and Sum of Sales, sort descending by Sales.

  2. Right-click the Customer Name pill on row and select Filter:

    2 1 horizontal bar chart 123612 46
  3. Select the option Use All:

    2 1 horizontal bar chart 123612 47
  4. Go across to ‘Top’ and select by field. You want to select Top 20 by Sales and Sum. These options are all changeable. Click OK:

    2 1 horizontal bar chart 123612 48
  5. This displays the top 20 customer names by the sum of sales:

    2 1 horizontal bar chart 123612 49

Discussion

Top N filters can be used with parameters, which allow the user to do a Top N selection. To get the filter options back up, click the customer name pill that is on the filters and select the edit filter. Where you have put 20, click the drop down. Click create a new parameter (Recipe 2.1.2):

2 1 horizontal bar chart 123612 50

Change the name to Number of Customers. Notice how Tableau has automatically chosen a range for you. You can change this range depending on your data and add in a step size. Let’s change the minimum and step size to 5. Click ok:

2 1 horizontal bar chart 123612 51

Once you have clicked OK to change the filter. The parameter control automatically shows and you can click through the different number of customers:

2 1 horizontal bar chart 123612 52

1.11 Stacked Bar Chart

Problem

You want to see total sales split by gender and sub-category

Solution

  1. Create a horizontal bar chart using Sub-Category and Sum of Sales, sorted descending by sum of sales.

  2. Add the dimension [Gender] to the colour marks card:

    2 1 horizontal bar chart 123612 53
  3. To change the colours, click the colour marks card and edit colours:

    2 1 horizontal bar chart 123612 54
  4. To adjust the colours you need to select the data item on the left and then pick a colour from the right colour palettes. If you double click the data item you will get the colour pick option:

    2 1 horizontal bar chart 123612 55
  5. Once you have selected ok, this will be your final view:

    2 1 horizontal bar chart 123612 56

Discussion

Stacked bar charts are useful for showing potential relationships in your data and to display an extra level of detail. To enhance this chart type, you might want to add labels to each gender and a total per Sub-Category. To get the labels per gender click this “T” button in the toolbar.

2 1 horizontal bar chart 123612 57

To add the total value per subcategory, you will need to add a reference line. To get a reference line, right-click on the sales axis and click add reference line. Change the scope to ‘Per Cell’, then change the value aggregation to ‘Sum’ and finally change the label to say ‘Value’. Click ok.

2 1 horizontal bar chart 123612 58

Notice how two of the labels are to the left of the reference line.

2 1 horizontal bar chart 123612 59

To right align all the reference labels, right-click on the reference line, select format. Change the alignment to horizontal right align and vertical middle align.

2 1 horizontal bar chart 123612 60

The chart now shows the values per gender, but also the total value per Sub-Category:

2 1 horizontal bar chart 123612 61

1.12 100% Stacked Bar Chart (Percent of Total)

Stacked bar charts are perfect for showing categorical splits of data, but it doesn’t allow for a comparison across the Sub-Categories for the genders.

Problem

You want to see what percentage each gender buys from each Sub-Category by using percent of total.

Solution

  1. Create a horizontal stacked bar chart, split by gender, by sum of sales, sorted descending by sum of sales, or duplicate sheet from 2.2.

  2. Right-click sum of sales in the columns and go down to quick table calculation, then click the percent of total option:

    2 1 horizontal bar chart 123612 62
  3. Tableau automatically performs the table calculation ‘Table Down’. Table Down uses the fields in Rows and on detail. In this example table down means it will compute the percent of total per gender per Sub-Category. For this example, you will want to compute using just Gender

  4. Right-click on the sum of sales in columns and select compute using, then change this to gender:

    2 1 horizontal bar chart 123612 63
  5. If you don’t have percentage labels per gender, click the label on the marks card:

    2 1 horizontal bar chart 123612 64
  6. Tableau’s default decimals on percentages is 2, but this can be too precise. Right-click on the sum of sales pill in columns and click format:

    2 1 horizontal bar chart 123612 65
  7. On the format pane, click Numbers, then percentage, and finally change to 0 decimal place:

    2 1 horizontal bar chart 123612 66
  8. This is what your final view should look like:

    2 1 horizontal bar chart 123612 67

Discussion

100% stacked bar charts are ideal for comparing each bar intuitively. The percent of total allows the user to see the percentage of each gender regardless of the total value for that subcategory. In reference to the solution, the chart allows you to see more females buy from the Labels subcategory than males and males bought more from supplies than females. This type of chart adds deeper analysis.

Tip

When you see an upward triangle on a green pill, that means it is a Table Calculation: <02in68> Table Calculations are dynamical and compute using the data you have in your view.

1.13 Discrete Bar in Bar Chart

Problem

You want to easily compare the sum of sales between Male and Female customers.

Solution

  1. Create a horizontal bar chart showing Sub-Category and Sum of Sales, sorted descending by sum of sales, or duplicate sheet 2.2.

  2. Press Control (Command on Mac) and click Gender to add it to Size.

    2 1 horizontal bar chart 123612 69
    Tip

    Pressing control (command on Mac) duplicates the pill you are dragging.

  3. Tableau automatically stacks measures and values on top of each other, because tableau aggregates all the measures. For this example we want to compare males to females which requires turning stack marks off. To do this, go to analysis in the top toolbar and turn stack marks off:

    2 1 horizontal bar chart 123612 70
  4. This creates a bar in bar chart to show the difference between male and female sales.

    2 1 horizontal bar chart 123612 71
  5. When you add a dimension or measure to size, a size legend will appear on the right hand side of the view. You can change the size sort order of the gender by dragging Males above Females in the size legend on the right side of the sheet:

    2 1 horizontal bar chart 123612 72
  6. Which then makes the chart look like this:

    2 1 horizontal bar chart 123612 73

Discussion

This chart type is useful for comparing between either two discrete dimensions (Male vs Female) of two measures (Budgets vs Actuals see recipe 2.3.1).

1.14 Shared Axis

You might have a data set that has multiple measures in different columns. A shared axis will allow you to compare two or more measures on one axis. This is especially beneficial if the measures are on a similar scale.

Problem

You want to compare sales and target side by side per category.

Solution

  1. Create a horizontal bar chart using Category from the monthly targets tables and Sum of Sales.

    2 1 horizontal bar chart 123612 74
  2. Click, hold, and drag category target to the sales axis, until you get two green rulers side by side. This means you are creating a shared axis.

    2 1 horizontal bar chart 123612 75
  3. The final chart should look like this:

    2 1 horizontal bar chart 123612 76

Discussion

Shared axes are useful if you have many measures with similar scales. Notice the new pills on rows and columns, measure names and measure values. Measure Names has also appeared on filters, and a measure values shelf has appeared below the marks card. These are all signs you are using a shared axis.

2 1 horizontal bar chart 123612 77

1.15 Shared Axis Bar in Bar

Recipe 2.3 showed us how to create a shared axis which is useful to show many measures on one axis. When trying to compare only two measures, a shared axis bar in bar chart might be more useful.

Problem

You want to show sales per category against a target.

Solution

  1. Create a bar chart using category from monthly targets table, target (Recipe 2.3), and sum of sales, or duplicate recipe 2.3.

  2. This creates a side by side shared axis chart, like below:

    2 1 horizontal bar chart 123612 78
  3. Move measure names from Rows to Colour. Press Control (Command on Mac) and duplicate measure names to size:

    2 1 horizontal bar chart 123612 79
  4. Tableau automatically stacks measures and values on top of each other, because tableau aggregates all the measures. For this example you will need to unstack the marks. Go to Analysis, in the top toolbar, and turn stack marks off.

    2 1 horizontal bar chart 123612 80
  5. Charts like this should have a clear focus and it is recommended that you mute the target colour to grey and have the sales as a colour of your choice for easier viewing. You will then be left with this chart.

    2 1 horizontal bar chart 123612 81
  6. You can adjust the sizes using the size legend:

    2 1 horizontal bar chart 123612 82

Discussion

As mentioned in 2.2.2 this chart type is useful for comparing between either two measures (Budgets vs Actuals) or two discrete dimensions (Male vs Female). Be wary of using too many colours when creating charts like these as it can cause the user, interacting with the visualisation, to not know where the key insights are when you use too many colours.

1.16 Bullet Chart

Problem

You want to compare Category Sales to Targets and see where 60 & 80% of the target was.

Solution

  1. Multiselect Category from monthly targets, Sales, and Targets. Click show me and find the bullet chart (Bottom Middle Chart). Tableau hasn’t highlighted this as the recommended chart type but has still shown it as an option (marked in black below).

    2 1 horizontal bar chart 123612 83
  2. This will automatically create a bullet chart to show the Sales vs. Targets, and where the 60% and 80% of the target should be using a reference line and reference bands..

    2 1 horizontal bar chart 123612 84

Discussion

The bullet chart is useful for comparing one measure against another, but also provides a reference point for where 60% and 80% of the target was. If you find that Tableau has used the wrong reference line field you can swap it by right-clicking on the axis and selecting swap reference lines. This will swap target and sales around meaning the target is now the bar and the sales is the reference line:

2 1 horizontal bar chart 123612 85

If you want to change the 60-80% reference band, right click on the reference band and then click edit.

2 1 horizontal bar chart 123612 86

Here you can change it to different percentages, use percentiles, quantiles, or standard deviations, and you can also change the formatting of the reference band.

2 1 horizontal bar chart 123612 87

1.17 Histogram

A histogram chart shows the distribution and frequency of the data.

Problem

You want to find the distribution of quantity by number of orders.

Solution

  1. Select quantity from the tables on the left. Click Show Me and then click the Histogram chart.

    2 1 horizontal bar chart 123612 88
  2. This automatically creates a histogram to show the number of orders that have purchased N quantity. Tableau has also automatically created a new field called Quantity (bin).

    2 1 horizontal bar chart 123612 89
  3. You can also change the size of the bins, by right-clicking on [Quantity (bin)] and changing the bin size to 2.

    2 1 horizontal bar chart 123612 90

Discussion

This chart shows how many items are in the order. There were over 4000 orders that had greater than 2 but less than 4 items in the order.

2 1 horizontal bar chart 123612 91

This type of chart shows the distribution in your data using equal bin sizes. The bin sizes can be static as the solution provided or you can use a parameter to let the user choose the bin size.

1.18 Soundwave

Bar charts are heavily used in data analytics, the soundwave chart is a version of the bar chart. It uses the standard bar chart approach as mentioned previously, but it has an extra step to allow the same data to be replicated above and below. The soundwave chart can be used to enhance the visualisation of volume.

Problem

You want to visually see the quantity of each order in the latest year of data.

Solution

  1. Drag [Order Date] to filters and select the Month / Year. Tick the box, at the bottom, that says Filter to the latest date value when the workbook is opened, then click OK.

    2 1 horizontal bar chart 123612 92
  2. Double click [Quantity] and double click [Order ID].

  3. Duplicate the Sum([Quantity]) pill on rows. Double click the second pill and add - to the front. Then press enter:

    2 1 horizontal bar chart 123612 93
  4. To format this, right-click the axis and untick the show header option. Then right-click the [Order ID] pill on columns and also untick the show header option:

    2 1 horizontal bar chart 123612 94
  5. You now have a sound wave chart which looks at how much quantity was purchased by each order:

    2 1 horizontal bar chart 123612 95

Discussion

Soundwave charts are great for showing volume. This type of chart enhances the extreme values. For example you can see that this particular order (CA-2020-117457) has the highest value for quantity:

2 1 horizontal bar chart 123612 96

This chart is a different way of showing the same data and would suit using call centre data, where the length is the number of minutes on a call, or word counts. The reason it is called a sound wave chart is because it looks like an audio wave chart.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.232.169.110