Create Bins in Tableau

Recently, while analysing Sales data in Tableau, I wanted to see how many customers are in different purchase ranges, such as small buyers, medium buyers, and high-value customers. Initially, I attempted to filter and group them manually, using the calculated fields.

Then, I discovered a straightforward solution to categorise the measures into equal-sized ranges using the Tableau Bins feature.

In this Tableau tutorial, I will explain how to create bins in Tableau using examples. Additionally, I will explain how to dynamically update the field bin size.

What are Bins in Tableau?

In Tableau, bins are pre-defined, equal-sized ranges or “buckets” used to group a continuous measure into discrete categories for analysis and visualisation. 

By creating bins, users can organise large datasets and trends, and create histograms to simplify complex data into distributions, such as grouping sales data into intervals like $0-$999, $1,000-$1,999, and so on.

Create Bins in Tableau

In the examples below, we will create bins in Tableau measure fields for different use case scenarios.

Example-1: Create Sales Bins in Tableau

In this example, we will create bins in the Sales measure to categorise customer purchase ranges.

Now, connect the Tableau with the dataset and follow the steps below to create bins.

  1. To create bins in Sales measure, go to the Data pane and select Sales -> Create -> Bins.
Create Bins in Tableau
  1. In this step, enter the label for the bin field. After this, enter the size of the bins. For example, if we take the bin size as 1000, then the size will be divided as 0-1000, 1000-2000 and so on.

After defining the size of bins, click OK.

Use Bins in Tableau
  1. To create the view, add the Sales bin to the Columns and records to the Rows.
  1. In this example, we will show the number of customers under a specific sales bin size. For this, click on the Customer Name in the Rows and select Measure ->Count.
Bin size in Tableau
  1. Now, change the Marks type to Bar. After this, press “Ctrl” and drag Customer Name (Count) to the Label card in the Marks section.
Create Bins in Tableau fields

With this, we can see a histogram chart showing each bin with a 1K range. In all bins, we can see the number of customers who have sales in the specific range.

Example-2: Create Profit Bins in Tableau

In this example, we will create bins for the Profit measure field. Using this bin, we can categorise Loss and Profit segments.

Now, follow the steps below to create a bin for the Profit field in Tableau.

  1. In the Data pane, click on the Profit field and select Create -> Bins.
Create Profit Bins in Tableau
  1. Enter the label for the bin field, and define the range for the bins. In this example, I have defined the range of profit bins as 1000, which will distribute the bins as 0-1000, 1000-2000 and so on.

After defining the bin range, click OK.

Create a bin size in Tableau
  1. To create the chart view, drag the Profit bin to the Columns and Customer Name to the Rows.
  1. To display the count of customers in each bin, change the customer name from discrete to continuous. For this, click on the Customer Name in Rows and select Measure -> Count.
  1. Now, to show the loss and profit values on either side, click on the Show Me tab and select Histogram chart.
Histogram chart with bins in Tableau

With this, we can see the number of customers in each bin where the range of profit is 500.

This way, we can create Profit beans in Tableau by following the above steps.

Dynamically Change Bin Size in Tableau

In Tableau, we can also change the bin size dynamically using a parameter. This parameter will have an input field, in which we can enter the bin size that will change dynamically on the chart.

In this example, I will use the Proft bin that we have created in the example above.

  1. To create a parameter, click on the dropdown in the Data pane and select Create Parameter.
  1. Define the details below to create the parameter that will control the bin size dynamically.
    • Enter the Name as Profit Bin Size.
    • Select the Data type as Integer.
    • The current value will be the size of the bin that will change dynamically.
    • Select the Minimum and Maximum values of the Range.
    • At last, select the Step size for the bins and click OK.
Create a Custom Bin range in Tableau
  1. Open the bin field Profit(bin) in the edit window, and in Value select the parameter Profit bin Size that we have created and click OK.
Change bin size dynamically in Tableau
  1. In the Data pane, click on the parameter Profit Bin Size and select Show parameter. With this, the parameter will be visible on the sheet through which we can update the bin size.
Use parameter to control bin size in Tableau

Now, we can see the parameter on the worksheet and in the input value, we can update the new bin size. As we change the bin size, it will also reflect in the chart.

Create a Dynamic bin size in Tableau

This way, we can dynamically update the bin size values in Tableau.

Conclusion

In this Tableau tutorial, we have learned how to create bins in Tableau for different use cases like categorising Sales ranges and separating Profit and Loss values. We also learned how to dynamically update the bin size using parameters to change its size.

By using bins, we can group continuous data into ranges, build histograms, and define distributions to analyse the data in Tableau.

You may also like to read:

live webinar

Data Cloud in Agentforce Data Library

In this live webinar, we will showcase how Salesforce AI Agents use business data and documents to provide intelligent responses using Agentforce Data Library and Salesforce Data Cloud.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.