Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to group by age?

Hi

In my script I load a table that is BirthYearMonth (ex 198201)

In a chart I wish to group the people by age-intervall,  0-12, 13-21 and 22->

In a other table I would like to use a diffrent age-intervall, 16-24, 25-> Is that possible and how to do it?

What would be the best way to do this? I would also like it to change when we get a new year and relode the script...

thanks!

1 Solution

Accepted Solutions
Not applicable
Author

Hi

I think the best way is to create a new field in the script with a calculation of the age like this :

age(    today() ,  makedate(left(Birthday,4) ,  right(Birthday,2) ,1))  as NbYear

age return the number of year between the 2 dates.

Then in the chart add a new dimension :

if(  NbYear <= 12  , '0-12'  , if( NbYear < =21 ,  '13-21' ,  etc...)))

hope that help

JJ

View solution in original post

1 Reply
Not applicable
Author

Hi

I think the best way is to create a new field in the script with a calculation of the age like this :

age(    today() ,  makedate(left(Birthday,4) ,  right(Birthday,2) ,1))  as NbYear

age return the number of year between the 2 dates.

Then in the chart add a new dimension :

if(  NbYear <= 12  , '0-12'  , if( NbYear < =21 ,  '13-21' ,  etc...)))

hope that help

JJ