Creating a Bar chart

Bar chart is one of the most commonly used chart type that will help us quickly compare information across various categories. In a bar chart, the height (in the case of a vertical bar chart) or the length (in the case of a horizontal bar chart) of the bar is what determines the value. They are very effective when we want to split our quantifiable data into different categories and find quick trends in the data, for example, the number of sales across different customer segments, the profit across various product categories, and so on. The bar chart in Tableau uses the Bar mark type.

Getting ready

In the following recipe, we will continue working in our existing workbook to create a bar chart that shows the sales across different regions. We will use the Sales field from the Measures pane and the Region field from the Dimensions pane. Let's see how this is done.

How to do it…

  1. We will create a new worksheet by pressing Ctrl + M on your keyboard and rename it to Bar chart.
  2. Next, we will drag Region from the Dimensions pane and drop it into the Columns shelf.
  3. Then, we will drag Sales from the Measures pane and drop it into the Rows shelf. Once we do this, we will see the view as shown in the following image:
    How to do it…
  4. This is how we can create a Bar chart in Tableau. Further, to see the Sales value on top of the bars, we will again drag Sales from the Measures pane and drop it into the Label shelf in the Marks card. Refer to the following image:
    How to do it…

How it works…

In the first chapter, we read about the Rows and Columns shelves. Since we place Region in the Columns shelf, we get a column for each region; Sales in the Rows shelf creates the y axis.

This is because a continuous field, such as Sales, will result in an axis being drawn when placed in the Rows or Columns shelf. However, a Discrete field, such as Region, will result in the headers being drawn when placed in the Rows or Columns shelf.

We could have also created the same bar chart using the Show Me! button, and to do this, we simply have to select Region in the Dimensions pane and do a Ctrl + Select on Sales in the Measures pane first. Then, click on the Show Me! button to select the Bar chart option, which is already highlighted with a Brown border. Refer to the following image:

How it works…

Once we select the Bar chart option from Show Me!, we will get a horizontal bar chart that can be made vertical by swapping the Rows and Columns shelves by clicking on the Swap button in the toolbar. Refer to the following image:

How it works…

Tip

The default bar chart created using Show Me! is a Horizontal bar chart that can later be converted into a Vertical chart by using the Swap option, as seen in the preceding screenshot.

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

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