Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ASK.. Set range in value

hello all, need helpp 😄

in my customer database has a [BirthDate] field.

to get customer age,

i use :

year(today() - year(BirthDate) as Age,

and, in pie chart

i use dimension [Age], and expresion [sum(sales)],

from that i can see Sales by Customer Age.

but the problem is,

the pie chart show in all age. not in range

the question is,

can i set range between age in pie chart?

i have already tried class function, CLASS(Age,10,'Age_Range')

but the result is not good enough, because the range between age is fix by 10.

i want to set a diferrent range in age,

this is my range between age,

>=80

60 - 79

40- 59

30-39

20-29

<=19

i have tried load it by INLINE too, but it doesn't work properly,

maybe wrong in syntax, plis help me

what is the INLINE LOAD syntax?

this is what i type,

LOAD * INLINE [

Age, Age_Range

>= 80, 80 Above

>=60<=79, 60 - 79

>=40<=59, 40- 59

>=30<=39, 30 - 39

>=20<=29, 20 - 29

<=19, Under 19

];

the syntax above won't work,

plis can somebody help?

regards...

Thank you before

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

You can create a new field 'Age Range' in your script as follows,

if(Age<20,'Under 19',if(Age>=20 and Age<=29,'20-29',if( Age>=30 and Age <=39, '30 - 39',if(Age>=40 and Age<=59, '40- 59',if(Age>=60 and Age<=79, '60 - 79','80 Above')))))

You can use the above field as dimension in the chart and get the desired output.

-Haneesh

View solution in original post

14 Replies
Not applicable
Author

anybody help pliss...

thank you

Not applicable
Author

anybody help pliss...

thank you

Not applicable
Author

Hi,

You can create a new field 'Age Range' in your script as follows,

if(Age<20,'Under 19',if(Age>=20 and Age<=29,'20-29',if( Age>=30 and Age <=39, '30 - 39',if(Age>=40 and Age<=59, '40- 59',if(Age>=60 and Age<=79, '60 - 79','80 Above')))))

You can use the above field as dimension in the chart and get the desired output.

-Haneesh

suniljain
Master
Master

Haneesh's Script will perfectly working. I used Same logic in Finance Application

Not applicable
Author

hello haneesh,

thank you for your reply,

but, where did i type this syntax?

if(Age<20,'Under 19',if(Age>=20 and Age<=29,'20-29',if( Age>=30 and Age <=39, '30 - 39',if(Age>=40 and Age<=59, '40- 59',if(Age>=60 and Age<=79, '60 - 79','80 Above')))))

in 'edit script' or in field expression, or where??

Not applicable
Author

hello sunin, where must i type that script?

suniljain
Master
Master

Dear Friend,

There are two way to write this script

1) In Experession of Chart

2) Script Level

I will suggest you to write at Script Level.

gandalfgray
Specialist II
Specialist II

In the script - in the same "Load" statement where you load the Age dimension

Not applicable
Author

Hi,

You should include this expression in the load statement where you load the Age field.

-Haneesh