What are Bins in Tableau?
Tableau bins are discrete fields that have equal-sized buckets. Using bins, you can manage your data points from a measure (continuous) into buckets based on specific ranges. Tableau can group similar data values from a continuous measure to create a set of bins by referencing a dimension.
For example, if your Tableau chart contains a field Sales on the Rows shelf and Category on the Columns shelf, then each sales value can be sorted into a bin corresponding to the Category values. Similarly, you can also create a numeric bin for your measure without referencing any dimension. In such a case, each bin shall correspond to a range of values. Tableau will create a new dimension each time you create a bin from a measure. Bins are highly useful tools as they can allow you to represent complex data sets by aggregating them into a sizeable number of buckets.
Tableau supports in-built functionality for creating a bin for your measure. In the next section, we will outline a step-by-step guide for creating bins in Tableau.
Table of contents
Key Takeaways
- The Tableau bins are the discrete fields that have equal-sized buckets based on specific ranges.
- Tableau can group similar data values from a continuous measure to create a set of bins by referencing a dimension. You can also create a numeric bin for your measure without referencing any dimension known as numeric bins.
- You can create bins in Tableau by selecting a measure and choosing Create – Bins…
- You can further customize bins or delete them as per your requirements
- Consider the limitations of the Tableau bins before you recommend them.
How to create Bins in Tableau?
To create bins in Tableau, follow the steps below:
Step 1: Import your dataset into Tableau by connecting your dataset and using the File Navigator.
Step 2: In the new worksheet, right-click on a measure in the Data pane. Select Create – Bins.
Step 3: In the Edit Bins [Net Profit (bin)] dialog box, specify a New field name for the new field.
Step 4: You can specify the bin size manually or create a new parameter to create Tableau bins of different sizes dynamically.
You can also use the Suggest Bin Size functionality, where Tableau will provide you with bin size suggestions.
When you specify the bin size, Tableau will create a set of bins, each of which has a size of 2144.
By default, Tableau displays a bin size on the Edit Bins window if it can quickly perform the optimized calculation. However, if Tableau fails to perform quick optimized calculations, then the bin size defaults to 10.
If Tableau can perform the optimizing calculation quickly enough, the value you initially see in the size of bins is Tableau’s estimate of the optimal bin size. You can use the Suggest Bin Size feature to enforce Tableau to perform the optimized calculations.
Tableau uses an algorithm to calculate the optimal size of a bin as per below:
Number of Bins = 3 + log2(n) * log(n)
n = number of unique rows in a table.
The bin size of each bin is calculated as = (Difference between the smallest and the largest values) / the number of bins.
There are 4 read-only fields available in the lower part of the Edit Bins window.
The definitions of these values are specified below.
Min | Minimum value of the field |
Max | Maximum value of the field |
Diff | The difference between the minimum and maximum values of the field |
CntD | The number of distinct values in the table data |
Once you click on OK, you will see a new binned field appear in the Dimensions area of the Data pane.
By adding a binned field to the view, Tableau allocates an equal-sized container for each bin. Each bin summarizes data for a range of values with lower and upper limits. Tableau bins show range of values in your data visualization.
Note: You can also create Tableau bins calculated field to create Tableau bins of different sizes.
In the next section, let’s look at some of the uses of bins in Tableau.
Uses of Bins in Tableau
- Once you have created a bin in the Data pane, you can create a histogram using that binned dimension. It will help you to visualize the distribution of your dataset along with a view of data outliers, skewness, or any other central tendency measures.
- For example, in this case, we have created a histogram using the Net Profit (bin) in the view. As you can see, the Tableau bins show range of values within each bin.
- You can also group the data for your analysis to gain an understanding of trends within a specific data range.
- Similarly, you can use the bins to simplify complex and large datasets with continuous measures for easy interpretation and management.
- Binning can be helpful in simplifying visualizations with large datasets, making them more manageable and interpretable.
Let’s now look at different examples involving the Tableau bins in detail through a step-by-step guide.
Examples
In this section, we will go through different examples demonstrating the creation and deletion of Tableau bins in your visual.
Example #1 – Customize bins
In this example, we will create a customized bin in Tableau using the Medical Insurance Cost dataset. The Medical Insurance Cost dataset encompasses various factors influencing medical expenses, such as age, sex, BMI, smoking status, number of children, and region.
To create a customized bin in Tableau, follow the instructions below:
Step 1: Connect with Medical Insurance Cost to Tableau using the File Navigator. Post successful import, you may navigate to the Data Source tab in Tableau to view the data.
Step 2: Click on a new worksheet. You will be able to view the imported dataset in the Data pane along with the data fields for the dataset.
Step 3: Click on the down arrow next to a measure. In this case, we will create a customized bin for the measure, Charges.
Step 4: Select Create – Bins… from the context menu.
Step 5: On the Edit Bins [Charges (bin)] window, provide a meaningful name for the bin. Specify the size of the bin. By default, Tableau provides an optimal bin size. You can manually change the bin value as well.
Once the details are entered, click on the OK button to save the changes.
Step 6: Once the changes are saved, Tableau will create the bin which can be viewed in the Data pane. Here you can see the bin Charges (bin) has been created in the Data pane for the dataset.
Step 7: Now create a histogram in Tableau by dragging the newly created bin to the Columns shelf and Charges measure to the Rows shelf.
Step 8: Click on the down arrow next to the SUM(Charges) in the Rows shelf and select Measure(Sum) – Count.
Your Tableau histogram is ready for data visualization and further analysis.
Example #2 – Delete Bins
In this example, we will demonstrate how to delete bins in Tableau using the Popular Spotify Songs dataset. The Popular Spotify Songs dataset contains a comprehensive list of the most famous songs and most streamed songs as listed on Spotify such as Track Name, Artist, Released Year, Streams, etc.
To demonstrate deleting bins in Tableau, you may follow the instructions outlined below:
Step 1: Connect to the Popular Spotify Songs dataset into Tableau by using the File Navigator. You can view the dataset in the Data Source tab of the Tableau.
Step 2: In a new worksheet, click on the down arrow next to a measure in the Data pane. Select Create – Bins. Here, we will create a bin for the Streams measure.
Step 3: On the Edit Bins [Streams] window, provide the name of the New field name. Specify the bin size and click on the OK button.
Tableau will create a bin for your dataset as per the specification. You can view the newly created bin (Streams (bin)) in the Data pane.
Step 4: To delete the bin, right-click on the existing bin and select Delete from the context menu.
In this case, we will be deleting the newly created bin i.e. Streams (bin).
Once you select the Delete option, Tableau will delete the bin from your dataset as shown below.
Example #3
In this example, we will create a bin by customizing the bin size in Tableau by using the shopping_trends dataset. The shopping_trends contains various features related to customer shopping preferences, gathering essential information for businesses seeking to enhance their understanding of their customer base such as customer age, gender, purchase amount, preferred payment methods, frequency of purchases, and feedback ratings.
To create a customized bin in Tableau, follow the below step-by-step instructions:
Step 1: Connect to the shopping_trends dataset into Tableau. The imported data can be viewed in the Data Source tab in Tableau.
Step 2: In the Data pane, click on the down arrow next to the measure (Purchase Amount (USD)) and select Create – Bins…
Step 3: In the Edit Bins [Purchase Amount (USD)] window, provide the name of the bin. As you can see, there is by default bin size specified by Tableau as per the optimal calculation.
Step 4: Change the Size of bins to customize as per your visual requirements. Here we have changed the size from 5.3 to 10.
Click on OK to save the changes.
Step 5: Drag the newly created bin to Columns and Purchase Amount (USD) to the Rows shelf. You can notice that the x-axis is bucketed in the multiples of 10 as per the value we have specified in the bin.
Step 6: Click on the down arrow next to SUM(Purchase Amount (USD)) and select Measure (Sum) – Count.
Now you can view the Tableau Histogram in the view.
Important Things to Note
- Tableau bins can only be created for relational data sources.
- Any binned data fields can’t be used in Tableau calculations.
- You can create Tableau bins calculated field replicating a bin of a specific size. For example, (FLOOR([Profit]/10000)*10000) will create bins with a size of 10000
- To use the bins with cube data sources and Tableau bins calculated fields, you must drag the calculation to the dimensions pane.
Frequently Asked Questions (FAQs)
Tableau histograms are the visual representation of continuous data distribution. These charts group the data into equal-sized containers called bins and display the frequency of occurrences in the vertical (y-axis). To create a Tableau histogram, you will need to create bins. To create a Tableau histogram, you will need to create bins. However, you can’t visualize any bins directly in a visualization, unlike the histograms.
Yes, you can use the Tableau bins with geographic data for analysis of spatial distribution patterns. Some of these bins include:
• Spatial binning for exploring the data in geographies with similar size
• Irregular polygons for countries, regional territories, census details, etc.
• Other include square bins and hexagonal bins.
Yes, you can adjust the number of bins dynamically in Tableau. You can do so by choosing one of the below options.
• Create a Parameter
• Create a Tableau bins calculated field
Yes, you can create bins for date fields in Tableau. You may use the date bins to group the date values into an equal-sized range of values. Some of the date groupings that can be done include months, quarters, years, etc.
Recommended Articles
This has been a guide to What Is Tableau Bins. Here we explain how to create bin in tableau with uses, examples and points to remember. You can learn more from the following articles –
Leave a Reply