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: 
Anonymous
Not applicable

Year(num(Today()))-Year(DoB_Loy) as Age --- to create age buckets

I need to create age buckets for my model, but i think the Field 'DoB_Loy' needs to be reformatted for my script above to work, or the script above needs to be reformatted.

DoB_Loy format: 'YYYYMMDD'

Today format:      'DD/MM/YYY'

This is the complete script I have for creating the Age Buckets:

AgeTransactions:

LOAD num#(CardNo) as CardNo, Year(num(Today()))-Year(DOB) as Age

RESIDENT Member;

AgeBucketTrans:

LOAD * INLINE [

    StartAge, EndAge, AgeBucket,

    0, 20, '0-20'

    21, 30, '21-30'

    31, 40, '31-40'

    41, 50, '41-50'

    51, 60, '51-60'

    61, 70, '61-70'

    71, 100, '>70'

    2010,2010, 'Unknown'

];

AgeBuckets:

LEFT JOIN (AgeBucketTrans)

INTERVALMATCH (Age)

LOAD * INLINE [

    StartAge, EndAge

    0, 20

    21, 30

    31, 40

    41, 50

    51, 60

    61, 70

    71, 100

    2010,2010

];

BandJoin:

LEFT Keep (AgeTransactions)

LOAD *

RESIDENT AgeBucketTrans;

drop table AgeBucketTrans;

Please help! Thanks!

1 Reply
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this

=Age(Today(), Date(Date#(DOB,  'YYYYMMDD')))

Hope this helps you.

Regards,

Jagan.