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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Lauri
Specialist
Specialist

Two set analysis conditions from one fact table

I'm trying to count the number of patients who meet two conditions:

  1. Age during the year was 18 to 85 AND
  2. Diagnosed with hypertension in the year or the prior year

I set up an "as-of" table linked to my fact table:

Lauri_0-1627400888215.png

[CC] contains values like 'Hypertension.' [AgeAtEvent] contains age values. The fact table looks like this:

Lauri_1-1627401235770.png

 

I am struggling with the set analysis to count these patients. This includes patients even when the CC condition is not met:

=Count({<PatientID=p({<IsSameYear={1}, AgeAtEvent={">=18<=85"}>})>*<PatientID=p({<[CC]={'Hypertension'}, YearDiff={"<2"}>})>} Distinct PatientID)

Thanks for any help!

2 Replies
stevejoyce
Specialist II
Specialist II

Are you missing the field in your P() ?

=Count({<PatientID=p({<IsSameYear={1}, AgeAtEvent={">=18<=85"}>} PatientID)>*<PatientID=p({<[CC]={'Hypertension'}, YearDiff={"<2"}>} PatientID)>}  Distinct PatientID)

 

But i don't think your calculation logically matches what you wrote.  Your first set doesn't include anything about CC, so first set will return PatientIDs between 18-85 and SameYear=1 (whatever this is).  The 2nd set will return all patient IDs who have CC = Hypertension, but doesn't include anythign about age.  So you will get patients who were 18-85 at some point in your data/filters and had hypertension at some age, but not necessarily the combination.

 

Why 2 sets for PatientID?  And not:

=Count({<PatientID=p({<IsSameYear={1}, AgeAtEvent={">=18<=85"}, [CC]={'Hypertension'}, YearDiff={"<2"}>} PatientID) >}  Distinct PatientID)

Lauri
Specialist
Specialist
Author

Thanks for the reply, Steve. I thought that the intersection of my two sets, using the * between them, would get me patients who meet both conditions. 

I can't put everything into one set because the fields [IsSameYear] and [YearDiff] would collide. They are in the As-Of Calendar.