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: 
Not applicable

Age Range in a pie chart

Hello,

I have some customer and their ages and I try to show a pie chart which show how much customer have less than 25 years, between 26 and 50, between 51 and 60 and more than 61. I have this code but it said that the field Age is unknown.

Load Customer,

        BirthDate,

        age(today(),BirthDate) as Age,

        if(Age<=25,dual('<=25',25),

        if(Age<=50,dual('26-50',50),

        if(Age<=60,dual('51-60'),

                         dual('>=61',61)))) as [Age Range]


What can I do ?

Thank you for your future help 😃

1 Solution

Accepted Solutions
Not applicable
Author

Try this:

Load

*,

if(Age<=25,dual('<=25',25),

        if(Age<=50,dual('26-50',50),

        if(Age<=60,dual('51-60'),

                         dual('>=61',61)))) as [Age Range];

Load Customer,

        BirthDate,

        age(today(),BirthDate) as Age

from abc.qvd;

or Try this:

Load Customer,

        BirthDate,

        age(today(),BirthDate) as Age,

        if(age(today(),BirthDate)<=25,dual('<=25',25),

        if(age(today(),BirthDate)<=50,dual('26-50',50),

        if(age(today(),BirthDate)<=60,dual('51-60'),

                         dual('>=61',61)))) as [Age Range]

View solution in original post

3 Replies
Not applicable
Author

Try this:

Load

*,

if(Age<=25,dual('<=25',25),

        if(Age<=50,dual('26-50',50),

        if(Age<=60,dual('51-60'),

                         dual('>=61',61)))) as [Age Range];

Load Customer,

        BirthDate,

        age(today(),BirthDate) as Age

from abc.qvd;

or Try this:

Load Customer,

        BirthDate,

        age(today(),BirthDate) as Age,

        if(age(today(),BirthDate)<=25,dual('<=25',25),

        if(age(today(),BirthDate)<=50,dual('26-50',50),

        if(age(today(),BirthDate)<=60,dual('51-60'),

                         dual('>=61',61)))) as [Age Range]

Not applicable
Author

Thank you ! =D

Not applicable
Author

Hello I have a similar problem. I have a BirthDate but not an age.. When I do the pie chart I set

=age(Today(),[BithDate])

as a calculated expression, but then the result is all of the ages of my customers. How can I get them represented as groups (20-30,30-40...)??

Thank you in advance