Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Lauri
Specialist
Specialist

Set Analysis with FirstSortedValue

I'd like to count the number of patients whose last blood pressure in the year was below 140. I am able to find the value of the last blood pressure like this in a chart:

=FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date)

This correctly returns the value every time.

When I try to count patients for whom this is true, it does not work. My measure:

=Count(distinct {<PatientID={"=(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date)<140)"}>} PatientID)

Any clues why this does not work? 

1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like below

Sum(Aggr(If(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date) < 140, 1), PatientID))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

3 Replies
MayilVahanan

Hi

Try like below

Sum(Aggr(If(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date) < 140, 1), PatientID))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sasikanth
Master
Master

HI, 

Try below expression

 

count({DISTINCT< PatientID={" =Aggr(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date),PatientID)<140"}>}PatientID)

Lauri
Specialist
Specialist
Author

Thank you both, Sasi and Mayil. You got me on the right track with Aggr, this way:

count(DISTINCT If(aggr({<IsSameYear={1}, AsOfYear>} FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date), PatientID, AsOfYear)<140, PatientID))