Tableau Binning Measures

Measures are fields that typically contain numeric information, such as sales or budget figures. When you place a measure on a shelf in Tableau Desktop, it creates an axis. However, sometimes you might want to organize the values of a measure into discrete groups. For example, suppose you have a measure that holds the ages of customers ranging from 18 to 90. Rather than break a view down by every age, you may want to analyze based on age groups (18 to 25, 26 to 33, and so on.). You can create these ranges by binning the data.
Say you are analyzing the sales performance for a retail store. One way to look at sales is in the form of a histogram, so you can see sales less than $500, between $500 and $1000, and so on. To build a histogram, first you would bin the sales total values into categories.
The following exercise builds upon this idea using the Superstore sample. You can download the attached Tableau workbook, binning_measures.twbx, to follow along.

Create Bins

Step 1

Open a new workbook and connect to the Superstore sample.

Step 2

In the Measures pane, right-click Sales) and select Create Bins.

Step 2

In the Create Bins dialog box, specify the size of the bins. In this example, type 500 in the Size of bins text box.

Step 3

Under Range of Values, click Load to load the minimum and maximum values for the field you are binning. This information helps you select a bin size that makes sense for your data.

Step 4

Click OK. Tableau creates a new dimension called Sales (bin).

Step 5

Drag Sales(bin) to the Rows shelf.
Notice that sales values are broken into $500 bins. Each bin label designates the lower limit (inclusive) of the bin’s range. For example, the bin labeled $1,000 contains numbers equal to or greater than $1,000, but less than $1,500.

Step 6

From the Measures pane, drag Sales to the Columns shelf.

Step 7

Right-click Sales on the Columns shelf and select Measure (Sum) > Count.
In the final view, each bar represents the number of transactions with sales amounts within each bin. You can now see that most sales at this superstore are for less than $500.

Create a calculated field to further customize bins

After you examine the result of the sales bin exercise in the previous section, you might determine that the values above $8,500 are outliers and should be grouped together. To group them, you can create a calculated field, and then create a bin from the calculation.

Step 1

In the Measures pane, right-click the measure you are interested in (in this case, Sales) and select Create Calculated Field.

Step 2

In the Calculated Field dialog box, complete the following steps.
  1. Specify the name. This example uses Adjusted Sales.
  2. In the Formula text box, build a formula to round the outliers to the value you want to use. This example uses the following formula:IF [Sales] >= 8500 THEN 8500
    ELSE [Sales] END

  3. Confirm that the status message indicates that the formula is valid, and then click OK.

Step 3

In the Measures pane, right-click Adjusted Sales and select Create Bins.

Step 4

In the Create Bins dialog box, do the following
  1. For Size of bins, type 500.
  2. Click Load to check that the bin size is appropriate, and then click OK.

Step 5

From the Dimensions pane, drag Adjusted Sales (bin) on top of Sales (bin) on the Rows shelf.
The diagram shows all sales that are over $8,500 at the $8,500 level.
Note: Aggregated formulas are not supported in bins.