All IT Courses 50% Off
Tableau Tutorials

Tableau Bins

Tableau bins are equal size containers that store data values corresponding to or fitting in bin size. We can also say that bins group a set of data into groups of equal interval or size, making it a systematic data distribution. Data from any discrete field can be used to create bins. Although Tableau users use measure fields mostly to create numeric bins. Bins are very useful in data analysis because they provide a systematic data range that helps us to organize information better and discover patterns easily.

Please note that we cannot use bins for calculations, and we can only create bins from relational databases. Also, while we create bins from measure fields, Tableau saves it as a new field because the bin comprises data values in a different form than the original measure field. For example, if you want to plot a graph showing sales against a range of ages from 15 to 80. Using the bin functionality, you can create bins for age groups and analyze sales for each age group. Bins are commonly used while creating histograms in Tableau.

How to Create Bins in Tableau?

Step 1: For creating a bin on a Tableau worksheet, right-click on the field name (measure or dimension) from where you will use data for the bin. Then, select Create and click on the Bins.

It will open a Create bins dialog box from where you can enter details and configure our bin. 

Tableau Bins

Step 2: From the dialog box Create Bins, you can set different parameters for the bin you wish to create. In the beginning, you are asked to enter a name for the new (bin) field. Next, you have to set the size of the bin. You can also click on the button Suggest Bin Size to get a bin size suggestion from Tableau for your selected data set.

All IT Courses 50% Off

In addition to this, you can set parameters to set a Range of Values like Minimum value, Maximum value, Difference, and CntD. Click on the OK once you have entered all the required parameters for a bin.

Tableau Bins

Step 3: The bin that you just created with the name Sales (bin) is available under the Data pane. You can use this bin field in visualization by dragging and dropping it on the Columns or Rows section.

Tableau Bins

The histogram has a bin field available on the x-axis and is created so that it drops sales per region in bins of size 1000 or 1K meaning all the sales values that fall under the range 0 to 1000 will occupy the 0K to 1K bin. Those values that fall between the greater than 1K to 2K range fall in the next bin and so on. In this way, the entire sales data is distributed in a range.

You can also edit an already existing Tableau bin by right-clicking on the bin name and selecting the Edit option. You can change any bin parameter from this dialog box as per your requirement.

Tableau Bins

How to create a Binned Dimension?

Step 1: In the Data pane, right-click (control-click on Mac) a measure and select Create > Bins.

https://help.tableau.com/current/pro/desktop/en-us/Img/calc_bins5.png

Step 2: In the Create Bins dialog box, accept the proposed New field name, or specify a different name for the new field.

A graphic depicting the Create Bins dialog
box.

Step 3: On the web, the dialog box is named Edit Bins and has a slightly different appearance, but the options remain the same. You can either enter a value in the Size of the bins field or allow Tableau to calculate a value for you.

If Tableau can perform the optimization calculation quickly, the value you see initially in the Size of bins is the Tableau’s estimate of the optimal bin size.

If Tableau cannot perform the optimization calculation quickly, the Size of bins field defaults to 10. In this case, you can also click Suggest Bin Size to have Tableau perform the optimization calculation.

The formula used to calculate an optimal bin size is

No. of Bins = 3 + log2(n) * log(n)

In the above formula, n is the number of distinct rows in the table. Each bin’s size is determined by dividing the difference between the smallest and the largest values by the number of bins.

After you click on OK to dismiss the Create Bins dialog box, a new binned field appears in the Data pane’s Dimensions area.

A graphic depicting a custom bin in the dimensions area of
the schema.

When you have added a binned dimension to the view, each bin will act as an equal-sized container that summarizes data for a specific range of values. Column or row headers will be created, where each bin label designates the lower limit of the range of numbers assigned to the bin. Note that the lower limit is inclusive.

How to create a Histogram from a Binned Dimension?

If you create a binned dimension, you can use it as the starting point for creating a histogram. Using the Sales (bin) dimension created according to the instructions above, use the following steps to create a histogram.

Step 1: Click the Sales (bin) dimension in the Data pane and choose Convert to continuous.

Step 2: Drag the Sales (bin) dimension from the Data pane and drop it on the Columns shelf.

Step 3: Drag the original Sales field from the Measures area of the Data pane and drop it on the Rows shelf.

Step 4: Click SUM(Sales) on Rows and change the aggregation from Sum to Count.

The result is a histogram:

https://help.tableau.com/current/pro/desktop/en-us/Img/calc_bins7.png
Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Back to top button