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.
In Tableau you can create a histogram using Show Me.
- Connect to the Sample - Superstore data source.
- Drag Quantity to Columns.
- 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.
- 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.)
- 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.
- 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.
- 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.
- 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.
- Right-click the CNT(Quantity) field on the Marks card again and select Edit Table Calculation.
- In the Table Calculation dialog box, change the value of the Compute Using field to Cell. Now we have the view that we want.