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

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

'if' problem

Hey , i want to create a listbox for age group.

Ex:

AgeGroup

1-10

10-20

20-30

30-40

40-50

Above 50

I am using:

 

if

(Age>=10, '1-10',
if(Age>=20, '10-20',
if(Age>=20, '20-30',
if(Age>=30, '30-40',
if(Age>=40, '40-50',
if(Age>=50, 'Above 50')))))) as

AgeGroup

But i am getting:

AgeGroup

1-10

can anybody please tell me what mistake i am doing..........

3 Replies
Not applicable
Author

the problem is all of them are >=10, son try using:

  

if

(Age>=50, 'Above 50',
if(Age>=40, '40-50',
if(Age>=30, '30-40',
if(Age>=20, '20-30',
if(Age>=10, '10-20','<10'))))) as

AgeGroup

MayilVahanan

Hi

     Try like this  

if

(Age<=10 and Age>=1, '1-10',
if(Age<=20, '11-20',
if(Age<=30, '21-30',
if(Age<=40, '31-40',
if(Age<=50, '41-50', 'Above 50'))))) as 

AgeGroup

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Please use CLASS!

class( expression, interval [ , label [ , offset ]] )

Creates a classification of expressions. The bin width is determined

by the number set as interval. The result is shown as a<=x<b, where

a and b are the upper and lower limits of the bin. The x can be

replaced by an arbitrary string stated in label. 0 is normally the

default starting point of the classification. This can be changed by

adding an offset.

Examples:

class( var,10 ) with var = 23 returns '20<=x<30'

class( var,5,'value' ) with var = 23 returns '20<= value <25'

class( var,10,'x',5 ) with var = 23 returns '15<=x<25'