Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
soniasweety
Valued Contributor III

four years

Hi all I want to calculate the age of less than 4years and  greater than 4yeras like attached how to calculate

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: four years

Age() is there in qlik. Try like:

If(Age(today(), yourdate)>=4, '>= four', '< four')

View solution in original post

8 Replies
olivierrobin
Valued Contributor II

Re: four years

hello,

something like this

if(Today()-MyDate>365*4-1,'gt than 4 years',

'less than 4 years')

YoussefBelloum
Esteemed Contributor

Re: four years

Hi,

tell us more about your data structure? what is your date field type ?

do you calculate the age from a range of dates or you are comparing with today date ?

soniasweety
Valued Contributor III

Re: four years

My date field is

started_on    = 10/26/2016 2:07:02 AM

yes its based on today date

MVP
MVP

Re: four years

Age() is there in qlik. Try like:

If(Age(today(), yourdate)>=4, '>= four', '< four')

View solution in original post

sasiparupudi1
Honored Contributor III

Re: four years

=Date(Addyears(Date#('10/26/2016 2:07:02 AM','MM/DD/YYYY h:mm:ss TT'),4))>Today()

YoussefBelloum
Esteemed Contributor

Re: four years

=if(Date(started_on)-AddYears(Timestamp(today()),-1)<1460,'less tha...','greater than..')

soniasweety
Valued Contributor III

Re: four years

done change in expression this is also working

if(((Date(Today(),'DD-MM-YYYY')

    -Date(Floor(Num([My_date])),'DD-MM-YYYY'))/365)>4,'Greater than 4 years','Lesser than 4 years') as by_Age,

MVP
MVP

Re: four years

I see few unnecessary (majorly formatting) functions, you can get rid of. The equivalent would be:

if((Today()-[My_date])/365>4,'Greater than 4 years','Lesser than 4 years') as by_Age,