A bar chart is the most commonly used chart types. It is split by categorical data and shows a continuous measure. There are two types of bar charts:
Horizontal Bar Chart
Vertical Bar Chart
Bar charts have other variations, like stacked bar charts, diverging bar charts, and histograms.
I. Horizontal Bar Chart
Let's see how to create a horizontal bar chart that shows, from highest to lowest, the continuous measure of sum of sales by the sub-category.
1. Create a new sheet.
2. Double-click Sub-category.
3. Drag the Sales measure to the columns shelf.
4. Hover over the axis to display a sorting bar icon. Click the icon to create a descending bar chart
II. Vertical Bar Chart
1. Create a new sheet
2. Double-click Sales.
3. Double-click Sub-category. This creates a vertical bar chart.
4. To convert this to a horizontal bar chart. click the "Swap Rows and Columns" button in the toolbar.
5. Click the Sort Descending button in the toolbar to convert the vertical bar chart to a horizontal bar chart in descending order.
Another way to create a Bar Chart
Click Sales.
Hold Ctrl (Command on Mac) and select Sub-Category and Sales.
On the top-right side of the view, click the Show Me tab.
Click the chart that Tableau highlights as best suited for the chosen dimensions.
5. Another way to sort the data is to right-click the Sub-Category field in Rows and click Sort.
6. Change to sort by Field
7. Change to Descending and confirm that the sorting is by sales and the aggregation is Sum.
The bar chart would be as below:
Adding a Constant Line
Bar charts are great for visualizing length as an indicator of a value and comparing whether a sub-category is above or below a constant line.
A constant line is a static reference line that allows you to enter a single value for reference.
Let's see how to add a constant line to our horizontal bar chart.
Continue with the horizontal bar chart and click the Analytics pane, next to the Data pane on the left side.
Click, hold, and drag Constant Line to the view.
3. Enter the value in the value box.
A constant line is useful when you have a specific target or reference point.
Changing to a User-Controlled Reference Line
A user-controlled reference line will allow the user to change the value of the reference line by using a parameter. Parameters are used to add interactivity to worksheets and dashboards.
Let's see how to add a user-controlled reference line.
Continue with the horizontal bar chart with the constant line.
Right-click the axis and select Edit Reference Line.
3. Click the drop-down and change the type to Sum.
4. Then click the Value box and change it to "Create a New Parameter".
5. Rename the parameter and change the value and click OK.
6. Customize the reference line by changing the Label drop-down to Value and then click OK.
Once you add a parameter via reference line, Tableau shows the parameter control, via which you will be able to change the reference line. Every time you change the parameter the reference line will move accordingly.
Adding Color to a Parameterized Reference Line
In case you need to see if each bar is above or below the controlled reference line, you can do so by using color.
Duplicate the above chart with the controlled reference line.
Create a calculated field and input the required calculation. Ex: Sum([Sales]) >= [Reference Line]
Add this calculated field to the Color shelf. You can find the calculated field under the list of fields in the Data pane.
Using color allows user to quickly see which sub-categories are above or below the reference line. Colors are very effective in data visualization. They are an example of pre-attentive attribute that allows us to process data very efficiently.