3 Replies Latest reply on Dec 1, 2018 1:52 AM by sarah.hussain

# Age bins from numeric data

Hello,

I am working on a data set that captures survey results.  I need to create following age bins for smoking status ( current, daily or previous smokers)

Group 1 : Age 18 to 29 years

Group 2: 30 to 49 years

Group 3 : 50 to 69 years

Group 4 : >70 years

I want to exclude all answers below age 18 years and am unable to edit alias in automated groups created by tableau. Is there a way to create custom bins or any other efficient way to make age groups? My workbook is attached . The column for age I need to use is "Q1 Age Numeric Question".  Would be grateful for any help. Thank you!

Sarah

• ###### 1. Re: Age bins from numeric data

Hi Sarah,

See if the below and newly attached 2018.3 workbook helps. Thx, Don

1 of 1 people found this helpful
• ###### 2. Re: Age bins from numeric data

Steps should be like below

If [Age] column is Measure then we can use Bins.

Bins: Right click on that Measure Column, click on "Bins".

## Step 1

Select Analysis > Create Calculated Field.

### Step 2

In the Calculated Field dialog box, complete the following steps.

1. For Name, type Age Groups.
2. In the Formula box, build the following formula, which defines several age groups:`IF[Age] < 21 THEN "Under 21"ELSEIF[Age] <= 32 THEN "21-32"ELSEIF[Age] <= 42 THEN "33-42"ELSEIF[Age] <= 52 THEN "43-52"ELSEIF[Age] <= 64 THEN "53-64"ELSE "65+"END`
3. Confirm that the status message indicates that the formula is valid, and then click OK.

## Create a view with the variable bin field

### Step 1

From the Measures pane, drag Number of Records to the Rows shelf.

### Step 2

From the Dimensions pane, drag the new Age Groups field to the Columns shelf.

All of the records are split into the six bins that you defined in the calculated field.

Note: To sort the bins, right-click Age Groups in the Columns shelf, and click Sort.

--------------

If [Age] column is Dimension then we can create a calculated field.

Regards,

Ritesh

1 of 1 people found this helpful
• ###### 3. Re: Age bins from numeric data

Thank you Don and Ritesh. That worked perfectly.