Sometimes we require discretizing (or binning) of numeric data for pretty labeling or meeting some format guidelines; for example, you may need to report the sales amount in thousands, and thus you will need to create a field that will put every sales amount in various bins, for example, 0-1000, 1000-2000, and so on.
Let's use the sample file Sample – Coffee Chain (Access)
. Open a new worksheet and select Sample – Coffee Chain (Access) as the data source.
Once the data is loaded on the worksheet, perform the following steps to discretize a numeric value or create bins:
200
, as shown in the following screenshot, and hit OK:When we hit the Load button on the Create Bins [Sales] dialog box, Tableau loads the distribution; that is, minimum, maximum, and the difference between the minimum and maximum value of the underlying measure. By looking at those values, we can decide the appropriate number of bins. Once we enter the number of bins, Tableau puts all the individual values of the underlying measure into bins, which start with zero and end with the highest possible value of the range that doesn't exceed the maximum value. For this recipe, we had the maximum value of 895 dollars and the maximum value of the bins was 800 dollars, because the next bin value would be 1,000 dollars and there are no values that are over 1,000 dollars.