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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Converting DOB to Age Range


I have Date of Birth as dd mmm yyyy format in Excel. Appreciate if you could let me know how to convert the DOB to different Age Ranges like;

Age (20 - 30)

Age (31- 40)

Age (41 - 50)

Age (51 - 60)

Age (61 - 70)

Age (71 - 80)

Thanks

Labels (1)
6 Replies
sushil353
Master II
Master II

Hi,

this is how you can do:

agegroup:
LOAD * Inline
[
Agemin,Agemax,group
0,5,0-5
5,10,5-10
10,18,10-18
]
;
age:
LOAD (now()-DOB)/365 as Age,* Inline
[
DOB,Name
12/28/2013,Pranya
09/05/2000, Ram
]
;
IntervalMatch (Age) LOAD Agemin, Agemax Resident agegroup;

HTH

sushil

MarcoWedel
MVP
MVP

Class(Age(today(), DOB),10)

MarcoWedel
MVP
MVP

Dual('Age ('&Replace(Class(Age(today(), DOB),10),'<= x <','-')&')',Class(Age(today(), DOB),10))

MarcoWedel
MVP
MVP

LOAD *,

    Age(today(), DOB) as Age,

    Dual('Age ('&Replace(Class(Age(today(), DOB),10),'<= x <','-')&')',Class(Age(today(), DOB),10)) as AgeRange;

LOAD Date(Today()-Ceil(Rand()*35000)) as DOB

AutoGenerate 300;

QlikCommunity_Thread_146550_Pic1.JPG

hope this helps

regards

Marco

Not applicable
Author

by using class function.        

Not applicable
Author

Hi

    Thanks for that. Appreciate if you could explain ,

  1. LOAD *,
  2. Age(today(), DOB) as Age,
  3. Dual('Age ('&Replace(Class(Age(today(), DOB),10),'<= x <','-')&')',Class(Age(today(), DOB),10)) as AgeRange;
  4. LOAD Date(Today()-Ceil(Rand()*35000)) as DOB
  5. AutoGenerate 300;

what these do, as I am new to Qlikview.

I also tried to edit my script using the above, but did not work. There is an error in the script. In fact I want to get a Chart "No. of Incidents By Age Range".  I also attached the QVW. Appreciate your help.

Thanks for your help