Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
Hi
Try like below
Sum(Aggr(If(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date) < 140, 1), PatientID))
Hi
Try like below
Sum(Aggr(If(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date) < 140, 1), PatientID))
HI,
Try below expression
count({DISTINCT< PatientID={" =Aggr(FirstSortedValue({<IsSameYear={1}, FactType={BP}>} [BP SYSTOLIC], -Date),PatientID)<140"}>}PatientID)
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))