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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
satishqlik
Creator II
Creator II

AgeBucket

I have created agebucket like this
  

     if(Age>=0 and Age<=25, Dual('<25 Yr',1),
      if(Age>25 and Age<=30, Dual('25-30 Yr',2),
       if(Age>30 and Age<=35, Dual('30-35 Yr',3),
        if(Age>35 and Age<=40, Dual('35-40 Yr',4),
         if(Age>40, Dual('>40 Yr',5),dual('NA',15)))))) as [Age Bucket],

Now I want avoid multliple If conditions

My script looks like as below but its not working.

If(Pick(Match(Age,Age>=0 and Age<=25,Age>25 and Age<=30,Age>30 and Age<=35,Age>35 and Age<=40,Age>40),
Dual('<25 Yr',1),Dual('25-30 Yr',2),Dual('30-35 Yr',3),Dual('35-40 Yr',4),Dual('>40 Yr',5)),dual('NA',15))


Please suggest where I did wrong.

Labels (1)
2 Replies
qlikview979
Specialist
Specialist

May be try  this

if(AGE<=25,Dual('<25 Yr',1),if(AGE<=30,Dual('25-30 Yr',2),if(AGE<=35,

Dual('30-35 Yr',3),if(AGE<=35,Dual('35-40 Yr',4),if(AGE<=40,Dual('40-45 Yr',4),Dual('NA',5)))))) as bucket

MK_QSL
MVP
MVP

,If(Not IsNum(Age),Dual('NA',1000),

  If(Age <= 25, Dual('<25 Yr',1),

  If(Age > 40, Dual('>40 Yr', 100),

  Dual(Replace(Class(Age-1,5),'<= x <','-')& ' yr',Class(Age-1,5))

  ))) as AgeBucket