Qlik Community

Ask a Question

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
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

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

View solution in original 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))