Identifying unique patients and categorizing by age (SUM-IF-Frequency Help)

astessman

New Member
Joined
Dec 3, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
I've collected some vaccine administration data that I want to analyze for unique patients in different age groups based on their registration date.
So far I have used a Sum - IF - Frequency equation to determine the number of unique patients depending on the date the patient was registered, however, I can't figure out how to adjust the formula to add in patient age to further dissect the data.

Here is the formula used for # of unique patients based on the date the patient was registered which would coordinate with I2 of the sample table below: Ctl+Shift+Enter: =SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=1,IF(Table2[Registration Date]<$P$2,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))

Vaccine Stats 2021 -11-08-2021.xlsx
ABCDEFGHIJKLMNOP
1Patient Full NameDispensed ItemPatient AgeRegistration DatePatient Registered# of Unique Patients# of VaccinesUnique Patients ≤11Unique Patients 12 to 17 yearsUnique Patients 18 to 49 YearsUnique Patients 50 to 64 YearsUnique Patients >65 yearsDates Used for Breaks
2Smith, JoeFluad Quad 2021-2022 Syringe768/2/2012< 9/1/2021359/1/2021
3Smith, JoeShingrix Vial Kit768/2/20129/1/2021 to 9/30/20213410/1/2021
4Franks, BobAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe2812/1/202110/1/2021 to 10/31/20214511/1/2021
5Dolan, JulieShingrix Vial Kit5210/22/202111/1/2021 to 11/30/20212212/1/2021
6Dillard, BillyPfizer-Biontech Covid-19 Vaccine Vial (eua)141/1/201512/1/2021 to 12/31/2021111/1/2022
7Doe, JohnPfizer-Biontech Covid-19 Vaccine Vial (eua)292/2/2018
8Doe, JohnAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe292/2/2018
9Smith, SherryPfizer-Biontech Covid-19 Vaccine Vial (eua)649/10/2021
10Winston, VanessaAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe529/21/2021
11Blake, WilliamAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe910/2/2021
12Doe, JenniferAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe711/12/2021
13Swindle, FrankShingrix Vial Kit5311/15/2021
14Rubble, BarneyPfizer-Biontech Covid-19 Vaccine Vial (eua)4910/29/2021
15Rubble, BettyAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe4810/29/2021
16Rubble, BettyPfizer-Biontech Covid-19 Vaccine Vial (eua)4810/29/2021
17Bacon, Chris P.Fluad Quad 2021-2022 Syringe669/8/2021
18Bacon, Chris P.Pfizer-Biontech Covid-19 Vaccine Vial (eua)669/8/2021
Sheet1
Cell Formulas
RangeFormula
I2I2=SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=1,IF(Table2[Registration Date]<$P$2,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))
J2J2=COUNTIFS(Table2[Registration Date],"<"&P2,Table2[Registration Date],">="&1)
I3I3=SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=$P$2,IF(Table2[Registration Date]<$P$3,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))
J3:J6J3=COUNTIFS(Table2[Registration Date],"<"&P3,Table2[Registration Date],">="&P2)
I4I4=SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=$P$3,IF(Table2[Registration Date]<$P$4,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))
I5I5=SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=$P$4,IF(Table2[Registration Date]<$P$5,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))
I6I6=SUM(IF(FREQUENCY(IF(1-(Table2[Patient Full Name]=""),IF(Table2[Registration Date]>=$P$5,IF(Table2[Registration Date]<$P$6,MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)))),ROW(Table2[Patient Full Name])-ROW($A$2:$A$2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.



In this example I need to be able to count the number of unique patients in each age category that correspond with the registration date. This is just a small sample of fake patient data, real sheet is over 700 lines and growing, but these are the main columns used from the master data.

Thank you for looking at my issue!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Welcome to the MrExcel forum!

I rearranged your output table a little so that I could use the same formula in every cell. It picks up the date range from the G:H columns, and it picks up the age range from the headers - the format of the last 6 characters must be the same.

Book1
ABCDEFGHIJKLMNO
1Patient Full NameDispensed ItemPatient AgeRegistration DateRegistration Range# of Vaccines# of Unique Patients (Age 00-99)Unique Patients (Age 00-11)Unique Patients (Age 12-17)Unique Patients (Age 18-49)Unique Patients (Age 50-64)Unique Patients (Age 65-99)
2Smith, JoeFluad Quad 2021-2022 Syringe768/2/201218/31/20215301101
3Smith, JoeShingrix Vial Kit768/2/20129/1/20219/30/20214300021
4Franks, BobAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe2812/1/202110/1/202110/31/20215410210
5Dolan, JulieShingrix Vial Kit5210/22/202111/1/202111/30/20212210010
6Dillard, BillyPfizer-Biontech Covid-19 Vaccine Vial (eua)141/1/201512/1/202112/31/20211100100
7Doe, JohnPfizer-Biontech Covid-19 Vaccine Vial (eua)292/2/2018
8Doe, JohnAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe292/2/2018
9Smith, SherryPfizer-Biontech Covid-19 Vaccine Vial (eua)649/10/2021
10Winston, VanessaAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe529/21/2021
11Blake, WilliamAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe910/2/2021
12Doe, JenniferAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe711/12/2021
13Swindle, FrankShingrix Vial Kit5311/15/2021
14Rubble, BarneyPfizer-Biontech Covid-19 Vaccine Vial (eua)4910/29/2021
15Rubble, BettyAfluria Quad 2021-22 (3 Year Up) 0.5 Ml Syringe4810/29/2021
16Rubble, BettyPfizer-Biontech Covid-19 Vaccine Vial (eua)4810/29/2021
17Bacon, Chris P.Fluad Quad 2021-2022 Syringe669/8/2021
18Bacon, Chris P.Pfizer-Biontech Covid-19 Vaccine Vial (eua)669/8/2021
Sheet26
Cell Formulas
RangeFormula
I2:I6I2=COUNTIFS(Table2[Registration Date],">="&G2,Table2[Registration Date],"<="&H2)
J2:O6J2=SUM(SIGN(FREQUENCY(IF((Table2[Registration Date]>=$G2)*(Table2[Registration Date]<=$H2)*(Table2[Patient Age]>=LEFT(RIGHT(J$1,6),2)+0)*(Table2[Patient Age]<=LEFT(RIGHT(J$1,3),2)+0),MATCH(Table2[Patient Full Name],Table2[Patient Full Name],0)),ROW(Table2[Patient Full Name])-ROW(INDEX(Table2[Patient Full Name],1))+1)))
Press CTRL+SHIFT+ENTER to enter array formulas.


Hope this helps!
 
Upvote 0
Wow! This is so much better. I can clunk my way through this sometimes, but this is a much more eloquent way of doing it Eric. Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top