Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Missing age groups

I am designing a QV app using data that I loaded in QV from an excel spreadsheet. The spreadsheet lists individuals with their ages. I tried to create age groups in QV scripting using the  age field and "if" statement but some of the individuals in the data were not assigned to any age group even though their age is included in the data both in QV and in the excel spreadsheet. How do I fix these missing age groups? could there be something wrong with the scripting? the script loaded fine.

LOAD *,

if([CMED Age] >20, 'Over 20',

if([CMED Age] <= 20 and [CMED Age] >= 16, '16 - 20',

if([CMED Age] <= 15 and [CMED Age] >= 11, '11 - 15',

if([CMED Age] <= 10 and [CMED Age] >= 6, '6 - 10',

if([CMED Age] <= 5 and [CMED Age] >= 4, '4 - 5',

if([CMED Age] <= 3 and [CMED Age] >= 1, '1 - 3',

if([CMED Age] < 1, 'Under 1'))))))) as [CMED Age_Group];

Thanks

13 Replies
maxgro
MVP
MVP

floor (or round or ceil) the age

or change the limit

LOAD *,

if([CMED Age] >20, 'Over 20',

if([CMED Age] <= 20 and [CMED Age] > 15,      '>15 - 20',

if([CMED Age] <= 15 and [CMED Age] > 10,      '>10 - 15',

if([CMED Age] <= 10 and [CMED Age] > 5,        '>5 - 10',

if([CMED Age] <= 5 and [CMED Age] > 3,          '>3 - 5',

if([CMED Age] <= 3 and [CMED Age] >= 1,        '1 - 3',

if([CMED Age] < 1,                                           'Under 1'

)))))))

as [CMED Age_Group];

Digvijay_Singh

Good catch maxgro‌, as script is working fine with normal cases. He may need to round the ages to nearest integer.

Not applicable
Author

Thanks Maxgro, I used the script:

round([Age (yrs)],1) as [CMED Age],

and it fixed the age groups for all the names.

Thanks everyone!!

sasiparupudi1
Master III
Master III

Please close this thread by marking a correct answer so that it will be helpful for others who might be looking for a similar solution