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 example. For this we are going to write the Custom SQL Query against the SQL Server Data Source so, Please visit Connecting Tableau to SQL Server article to understand the configurations. Custom SQL query we are going to use for this report is:
SELECT Prod.Productkey, Prod.EnglishProductName, Prod.Color, Prod.DealerPrice, Fact.OrderQuantity, Fact.TotalProductCost, Fact.SalesAmount FROM DimProduct AS Prod INNER JOIN FactInternetSales AS Fact ON Prod.ProductKey = Fact.ProductKey
Tableau Bins Example
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, Sales Amount will be aggregated to default Sum. Once you drag them, table report is generated as shown in the following screenshot.
From the above screenshot you can observe that, there are 158 row
Creating Tableau Bin
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 then select Bins option from the context menu as shown below.
Once you select Bins option, a new window called Create Bin will be opened with default Name and default bin size 10.
If you don’t know the bin size then click on the Load button. By clicking this button, Tableau desktop will display the Minimum, Maximum, Difference values and also the best possible Bin size as shown below
For now, We are using the Static Number 20 as Size of the bin and Click Ok
Below screenshot will show you the newly created Bin
Please replace Product Key dimension with Product Key Bin on Row Shelf
From the above screenshot you can observe that, Product Key Data is 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
Deleting Tableau Bins
It is very easy and straight forward 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 the context menu, Please select the Delete Option as shown below
Creating Stacked Bar Charts using Tableau Bins
Tableau allows us to create Bins on both Dimensions and Measures. In this example we will create Bins on Measure value and using that Bin value, We will create Stacked Bar Charts.
Following screenshot will show you, Default Bar Chart with Color dimension on Row Shelf and Sales Amount on Column Shelf
Right Click on the Sales Amount Measure and select Create Bins option from the context menu. For Now, we are using the default bin size generated by the Tableau Desktop (i.e., 357.598)
Next, Drag and Drop the newly created Sales Amount bin from Dimension region to the Color Option in Marks Card as shown below
Once you are done, You can see the Stacked Bar Chart As shown in below screenshot. Tableau Desktop allocate default colors to stacked bars but, You can edit the colors by selecting the Edit Colors.. option from the context menu.
Let us add the Data Labels and see, whether we successfully created the stacked bar charts using the Tableau Bins or not
Thank You for Visiting Our Blog