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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
cjett7769
Contributor II
Contributor II

Creating age filter

I am trying to create a filter in my Qlikview app for age. I am trying to create a multi box that allows us to select is a patient is 18 years or older, or younger then 18. I have a data field being pulled in from a sql statement Pat_Age. Any suggestions on how I can create those on screen filters would be appreciated.

5 Replies
sunny_talwar

May be something like this:

LOAD *,

          If(Age(Now(), Pat_Age) >= 18, '18 years or older', 'Younger then 18') as FlagField;

SQL Select *

FROM Source....;

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

The easiest is to create an extra field in the script based on Pat_Age:

LOAD

     ...lots of fields,

     Pat_Age,

     If(Pat_Age>=18,'18 or older','Under 18') as Is18plus;

SQL SELECT ... FROM ... ;

Then use the new Is18Plus field in your multibox.

Altermatively you can also use the expression If(Pat_Age>=18,'18 or older','Under 18') in your multibox


talk is cheap, supply exceeds demand
cjett7769
Contributor II
Contributor II
Author

Thanks Sunny for your assistance. Running into some issues. Here is what I have:

LOAD DOB,
"FULL_NM",
"PAT_KEY",
PAT_AGE,
"FlagField",
"PAT_MRN_ID";
SQL SELECT DOB,
extract (year from (age(current_date,dob))) as PAT_AGE,
If(Age(Now(), Pat_Age) >= 18, '18 years or older', 'Younger then 18') as "FlagField",

"FULL_NM",
"PAT_KEY",
"PAT_MRN_ID"

I don't know why the load of the data is failing.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Probably because your database server doesn't understand the Qlikview script syntax. Put the if statement in the preceding load like Sunny and I did in the examples we posted.


talk is cheap, supply exceeds demand
sunny_talwar

Something like this:

LOAD DOB,
"FULL_NM",
"PAT_KEY",
PAT_AGE,
"FlagField",
"PAT_MRN_ID",

If(Age(Now(), DOB) >= 18, '18 years or older', 'Younger then 18') as "FlagField";
SQL
SELECT DOB,
extract (year from (age(current_date,dob))) as PAT_AGE,
"FULL_NM",
"PAT_KEY",
"PAT_MRN_ID"