Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

age groups

hi guys, i have a age dimension and i need to use it as age groups ex:(0-5,6-12,13-19,20-40,41-above), any idea what to do?

1 Solution

Accepted Solutions
arasantorule
Creator III
Creator III

Hi,

If your age group is at constant intervals (5 to 10, 10 to 15, 15 to 20) the we can use class() function.

If it is of different intervals we can use if condition (if (Age>0 and Age <=5,'0-5').. etc. in scripting.

Thanks

View solution in original post

7 Replies
arasantorule
Creator III
Creator III

Hi,

If your age group is at constant intervals (5 to 10, 10 to 15, 15 to 20) the we can use class() function.

If it is of different intervals we can use if condition (if (Age>0 and Age <=5,'0-5').. etc. in scripting.

Thanks

Not applicable
Author

Hi Meena,

I did the sample example using the if function,

LOAD * INLINE [

    Emp, Age

    abc, 12

    xyz, 5

    pqr, 3

    aaa, 8

    bbb, 15

    ccc, 17

    yyy, 22

    zzz, 35

    ttt, 41

    ooo, 55

    rrr, 60

    qqq, 1

    www, 2

    ddd, 9

    kkk, 99

];

Write Expression in List box:

=if(Age>0 and Age <=5,'0-5',

  if(Age>5 and Age <=12,'6-12',

  if(Age>12 and Age <=19,'13-19',

  if(Age>20 and Age <=40,'20-40',

  if(Age>40 and Age >=41,'41-Above',Age)))))

AgeGroup.JPG

Thank You,

-YJ

martinpohl
Partner - Master
Partner - Master

I won't realize this in a listbox, that's not good for performance.

Create a new field in your datas (e.g. age_class)

if(Age <=5,'0-5',

  if(Age <=12,'6-12',

  if(Age <=19,'13-19',

  if(Age <=40,'20-40',

  ,'41-Above')))) as age_class,

Regards

Not applicable
Author

Hi Martin,

I did the demo example as just to understand easily.

otherwise u\you can used in backed i.e in the script.

Also I like to ask how the performance is not good while writing the example in expression in the listbox

Thanks,

-YJ

Not applicable
Author

Hi Meena,

You can try Interval Match.

Example:

Age_Groups:
load *inline
[
low,high
0,10
11,20
21,50
51,above

]
;

Sample2:
load *inline
[
name,CityId,age
Ana,1,5
Ara,1,9
brinda,1,20
cinda,1,22
ash,2,30
]
;

IntervalMatch(age)
load low as min_age,high as max_age
resident  Age_Group;

Renaming helps to remove synthetic keys.

Now in the chart you can use min_age &'-'&max_age. under dimension.

Hope this helps

Thanks,

Prajna

Anonymous
Not applicable
Author

thank you, the class worked for me but i couldn't change the x in the expression in the title of the graph, any idea how to work on that?

arasantorule
Creator III
Creator III

Hi Mena,

I am not sure on your query.

Could you please explain in detail.

If your requirement is to have a dynamic chart title, what exactly is your requirement.

Thanks.