# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Partner

## Need to group by age ?

In my data, I have only year of birth. So I used =Age(Today(), MakeDate(YearofBirth)) function to have Age in my dimension. Now, I need to group them in X-axis. Like from age 20-25, 25-30,30-40, above 40 years. In my measure I have employee count (Y-axis).  How do I do it.

Tags (1)
4 Replies
Honored Contributor II

## Re: Need to group by age ?

Hi,

Try to create logical column at back end script like below,

if(Age >=20 and Age<25,Dual('20-25 Years',1),

if(Age >=25 and Age<30,Dual('25-30 Years',2),

if(Age >=30 and Age<=40,Dual('30-40 Years',3),Dual('Above 40 Years',4)  as AgeBucket;

from table;

Buckets

Thanks,

Deva

Partner

## Re: Need to group by age ?

Thanks for the reply. Since there is no age column. I tried to load Age from Date of Birth using

SQL SELECT YearofBirth

FROM dbo.Employee;

So when I try to  add ur code. It says ,"

The following error occurred:

Honored Contributor II

## Re: Need to group by age ?

Hi,

like this?

Data:

if(Age >=20 and Age<25,Dual('20-25 Years',1),

if(Age >=25 and Age<30,Dual('25-30 Years',2),

if(Age >=30 and Age<=40,Dual('30-40 Years',3),Dual('Above 40 Years',4) )))  as AgeBucket;

load *, Age(Today(), MakeDate(YearofBirth)) as Age;

Customer, YearofBirth

Name1, 1980

Name2, 1988

Name3, 1968

Name4, 1971

Name5, 1984

Name6, 1975

Name7, 1969

Name8, 1990

Name9, 1987

Name10,1985

];

Honored Contributor II

Hi,