# Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save \$400. Learn More
New Contributor

## Age Bucket Expression Question

Hi,

I am wondering what is wrong with my expression.  The IF statement works with just the first part, but if I add in the second parameters, I get the error "Error in expression:  If takes 2-3 parameters".  Can anyone help me to correct the syntax so that I have the specified 3 buckets?

=
IF

(

(Round(  ((TODAY())-DOB)/365)  )            >=6

and

(Round(  ((Today())-DOB)/365)  )            <=17

)

,'6-17',

IF
(

(Round(  ((TODAY())-DOB)/365)  )            >17

and

(Round(  ((Today())-DOB)/365)  )            <=65

)

,'18-65','OTHER'

Tags (1)
1 Solution

Accepted Solutions
Valued Contributor

## Re: Age Bucket Expression Question

Hi Isabel. Maybe this

= IF(

(Round(  ((TODAY())-DOB)/365)  )            >=6
and
(Round(  ((Today())-DOB)/365)  )            <=17

,'6-17',

IF(

(Round(  ((TODAY())-DOB)/365)  )            >17
and
(Round(  ((Today())-DOB)/365)  )            <=65

,'18-65', 'OTHER'))

3 Replies
Valued Contributor

## Re: Age Bucket Expression Question

Hi Isabel. Maybe this

= IF(

(Round(  ((TODAY())-DOB)/365)  )            >=6
and
(Round(  ((Today())-DOB)/365)  )            <=17

,'6-17',

IF(

(Round(  ((TODAY())-DOB)/365)  )            >17
and
(Round(  ((Today())-DOB)/365)  )            <=65

,'18-65', 'OTHER'))

New Contributor

## Re: Age Bucket Expression Question

Yes, that's it, Perfect, Thanks!

New Contributor II

## Re: Age Bucket Expression Question

There were a few misplaced parentheses. The below should work.

=IF(Round(((TODAY())-DOB)/365)
>=6
and Round(((Today())-DOB)/365) <=17 ,'6-17',
IF(Round(((TODAY())-DOB)/365) >17 and Round((Today()-DOB)/365) <=65 ,'18-65','OTHER'))

Also, qlikview has a function for everything:

=IF(Age(TODAY(),DOB) >=6 and Age(TODAY(),DOB) <=17 ,'6-17',IF(Age(TODAY(),DOB) >17 and Age(TODAY(),DOB) <=65 ,'18-65','OTHER'))

To take it one step further you can do an interval match in the load to calculate the buckets.  If you'd like an example of that just reply and let me know.