Build a Histogram

A histogram is a chart that displays the shape of a distribution. A histogram looks like a bar chart but groups values for a continuous measure into ranges, or bins.

The basic building blocks for a histogram are as follows:

 Mark type: Automatic Rows shelf: Continuous measure (aggregated by Count or Count Distinct) Columns shelf: Bin (continuous or discrete). Note: This bin should be created from the continuous measure on the Rows shelf. For more information on how to create a bin from a continuous measure, see Create Bins from a Continuous Measure(Link opens in a new window).

In Tableau you can create a histogram using Show Me.

1. Connect to the Sample - Superstore data source.

2. Drag Quantity to Columns.

3. Click Show Me on the toolbar, then select the histogram chart type.

The histogram chart type is available in Show Me when the view contains a single measure and no dimensions.

Three things happen after you click the histogram icon in Show Me:

• The view changes to show vertical bars, with a continuous x-axis (1 – 14) and a continuous y-axis (0 – 5,000).

• The Quantity measure you placed on the Columns shelf, which had been aggregated as SUM, is replaced by a continuous Quantity (bin) dimension. (The green color of the field on the Columns shelf indicates that the field is continuous.)

To edit this bin: In the Data pane, right-click the bin and select Edit in Shelf.

• The Quantity measure moves to the Rows shelf and the aggregation changes from SUM to CNT (Count).

The Quantity measure captures the number of items in a particular order. The histogram shows that about 4,800 orders contained two items (the second bar), about 2,400 orders contained 4 items (the third bar), and so on.

Let's take this view one step further and add Segment to Color to see if we can detect a relationship between the customer segment (consumer, corporate, or home office) and the quantity of items per order.

4. Drag Segment to Color.

The colors don't show a clear trend. Let's show the percentage of each bar that belongs to each segment.

5. Hold down the Ctrl key and drag the CNT(Quantity) field from the Rows shelf to Label.

Holding down the Ctrl key copies the field to the new location without removing it from the original location.

6. Right-click (Control-click on a Mac) the CNT(Quantity) field on the Marks card and select Quick Table Calculation > Percent of Total.

Now each colored section of each bar shows its respective percentage of the total quantity:

But we want the percentages to be on a per-bar basis.

7. Right-click the CNT(Quantity) field on the Marks card again and select Edit Table Calculation.

8. In the Table Calculation dialog box, change the value of the Compute Using field to Cell.

Now we have the view that we want:

There’s still no evidence that the percentages by customer segment show any trend as the number of items in an order increases.

Check your work! Watch steps 1–8 in action:

Note: In Tableau 2020.2 and later, the Data pane no longer shows Dimensions and Measures as labels. Fields are listed by table or folder.