Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
baylor2016
Creator
Creator

How to get the number of patients whose last lab result is more than 9?

Hi Experts,

I am trying to find a way to get the number of patients whose last lab result is more than 9. I used this function, it does not give me the number correctly. Please help.

=sum(
if(AGGR(FirstSortedValue(A1C, -LABORDERDATE2), PAT_ID)>9, 1,0)
)

   

PAT_IDLABORDERDATE2EncounterIDA1CRANK
103/13/201717.81
209/01/201626.31
309/08/201637.01
405/30/201747.71
402/14/201757.52
410/17/201668.73
408/12/201678.64
507/11/201785.91
503/07/201796.32
508/30/2016105.03
604/03/2017117.51
706/06/2017127.51
803/22/20171312.01
906/14/2017147.41
1010/27/20161510.61
1105/17/20171611.01
1103/30/20171713.82
1109/20/20161815.13
1206/12/2017195.01
1212/07/2016205.82
1302/03/2017216.61
1403/02/2017229.91
1512/02/2016235.51
1606/29/2017248.21
1603/23/2017257.42
1707/19/2017267.91
1703/24/2017279.02
1804/14/2017289.01
1808/16/2016298.32
1907/18/20173011.31
2010/21/2016315.51

sample data and project attached

Thanks in advance

Longmatch

1 Solution

Accepted Solutions
effinty2112
Master
Master

Hi Haijunw,

Maybe:

=count(Aggr(if(FirstSortedValue(A1C,-Date#(LABORDERDATE2,'MM/DD/YYYY')) >9,PAT_ID),PAT_ID))

Regards

Andrew

View solution in original post

8 Replies
Anil_Babu_Samineni

May be?

=If(Sum(A1C) > 9, Count(LABORDERDATE2))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

Or this?

Count({<A1C = {'>9'}>} LABORDERDATE2)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
effinty2112
Master
Master

Hi Haijunw,

Maybe:

=count(Aggr(if(FirstSortedValue(A1C,-Date#(LABORDERDATE2,'MM/DD/YYYY')) >9,PAT_ID),PAT_ID))

Regards

Andrew

mostwanted123
Creator
Creator

Try this,

= Count({<A1C = {' > 9'}>}PAT_ID)

Regards,

Pratik Bhor

baylor2016
Creator
Creator
Author

Thank you for the quick solution. It works perfectly!!!

baylor2016
Creator
Creator
Author

Another question, if I need to get the  the number of patients whose last lab result is more than 9 in 2017, how to modify the script? Thanks

effinty2112
Master
Master

Hi,

Try:

=count({$<LABORDERDATE2 = {">=01/01/2017"}>}Aggr(if(FirstSortedValue(A1C,-Date#(LABORDERDATE2,'MM/DD/YYYY')) >9,PAT_ID),PAT_ID))

Regards

Andrew

baylor2016
Creator
Creator
Author

Not working. I created another post. You can answer my questions there.  I actually wanted to ignore a filter, but it does not work. The same method works in other script, not this one. Strange. Thanks