Tableau Bins

Tableau Bins are useful to create a Range of data, which is similar to SQL Buckets. In this article, we will show you How to Create Bins in Tableau with an example.

To create bins in tableau, we are going to write the Custom SQL Query against the SQL Server Data Source. Please visit Connecting Tableau to SQL Server article to understand the configurations. Custom SQL query we are going to use for this Tableau report is:

SELECT Prod.Productkey, 
FROM DimProduct AS Prod 
     INNER JOIN FactInternetSales AS Fact 
       ON Prod.ProductKey = Fact.ProductKey

Tableau Bins Example

Before we start creating bins in Tableau, we need a report. First, Drag and Drop the Product Key from Dimension Region to Rows Shelf. Next, Drag and Drop the Sales Amount from Measures Region to Filed region. Since it is a Measure value, the Sales Amount will aggregate to default Sum.

Once you drag them, the table report will generate, as shown in the following screenshot. You can observe that there are 158 row.

Tableau Bins 2

Create Bins in Tableau

In this example, we are going to create Bins or Buckets on Product Key. So, Please right-click on the Product Key dimension and select Create option and choose Bins option from the context menu.

Tableau Bins 3

Once you select Bins option, a new window called Create Bin will open with default Name and default bin size 10.

Tableau Bins 4

If you don’t know the bin size, click on the Load button. By clicking this button, the Tableau desktop will display the Minimum, Maximum, Difference values and also the best possible Bin size as shown below

Tableau Bins 5

For now, We are using the Static Number 20 as Size of the bin and Click Ok

Tableau Bins 6

It shows the newly created Bin in Tableau Dimension section

Tableau Bins 7

Please replace Product Key dimension with Product Key Bin on Row Shelf.

Tableau Bins 8

From the above screenshot, you can observe that Product Key Data organized into Buckets and the total rows are 21 only. To display the product keys available in each bin, Drag and Drop the Product key dimension to the Row Shelf

Tableau Bins 9

From the above screenshot, you can see the newly created bin in Tableau table report.

How to Delete Tableau Bins

It is effortless and straightforward to delete the Bins in Tableau. To do so, Select the Bin you want to delete, and right-click on it will open the context menu. From that, Please select the Delete Option as shown below

Tableau Bins 10

Create a Stacked Bar Chart using Tableau Bins

Tableau allows us to create Bins on both Dimensions and Measures. In this example, we will generate Bins on Measure value. Using that Bin value, we create a Stacked Bar Chart. The following screenshot will show you, Default Bar Chart with Color dimension on Row Shelf and Sales Amount on Column Shelf

Tableau Bins 11

Right Click on the Sales Amount Measure and select Create Bins option from the menu. Now, we are using the default bin size generated by the Desktop (i.e., 357.598)

Tableau Bins 12

Next, Drag and Drop the newly created Sales Amount bin from Dimension region to the Color Option in Marks Card as shown below

Tableau Bins 13

Once you complete, You can see the Stacked Bar Chart. Tableau Desktop allocates default colors to stacked bars but, You can edit the colors by selecting the Edit Colors.. option.

Tableau Bins 14

Let us add the Data Labels and see, whether we successfully created the stacked bar charts using the Tableau Bins or not.

Tableau Bins 15

Comments are closed.