# Group value as bins and rename the bins

I know how to group the values in a column, which is to use Bin function, but after that, how can I rename the bins from 1,2,3,4,5 to meaningful values?

Use Choose function to rename the bins.
Case study: you have a column which is about `Product ID` from 1-3000. And you would like to create 3 groups to see the value distribution. The groups are ID 1-1000 as Made 2010, 1001-2000 as Made 2011 and 2001-3000 as Made 2012.

Here are the steps:
1. Create bins: BinRange([`Product ID`], 1000, 2000, 3000). Then you will get a column `bin_field` and values show as 1,2,3. Note: Product ID needs to be a number column with β123β icon.

2. Replace the bin values with text:
Choose(`[bin_field]`, βMade 2010β, βMade 2011β, βMade 2012β). Then the value 1,2,3 will be replaced with Made 2010, Made 2011, Made 2012.

Fanfan, when you use a function like BinFixed([Sales], 0, 1000, 10), you are basically telling Sigma to break up any sales between 0 and \$1000 into 10 equal bins. Each bin is identified by its sequential number, 1 through 10, with any outlier getting into the bin # 11.

If you want to name the bins in a self-explanatory way, you have 2 options:

1. Encase your bin statement into an IF:
if( [SalesBin] = 1, β0-100β,[SalesBin] = 2, β101-200β,[SalesBin] = 3, β201-300β, βOTHERβ)

if([Sales] <= 100, β0-100β, [Sales] <= 200, β101-200β, [Sales] <= 300, β201-300β,βOTHERβ)

Thanks for the details, Yuri~ I think I used BinRange instead of BinFixed? With BinRange, it will set the bins based on the bracket I defined?

Woo, good to know that Case function is supported in Sigma! But I did not see it show up in Formula dialog

@Fanfan , you are right, CASE WHEN works when you write SQL, its Sigma function equivalent is if() .

Our if() supports multiple sections / choices and would look like this:

if( [SalesBin] = 1, β0-100β,[SalesBin] = 2, β101-200β,[SalesBin] = 3, β201-300β, βOTHERβ)

I corrected my initial reply above.

Thanks

1 Like