I have many rows (over 100,000). I want to figure out a way to get the unique counts of rows given certain parameters.

In my data set I have rows: Day, Month, Year, Physician ID, Patient ID, Encounter ID, Procedure Name

There are multiple procedures per Encounter. Patient IDs occur many times a month.

I want to know how many unique Patient IDs exist per month, per a certain physician.

A1 in a different sheet contains the Physician ID
A2 contains Procedure Name

A3:A15 are Month Names.
I want B3:B15 to populate.

An example of a formula I use sometimes {=SUM(IF(FREQUENCY(IF('EP Data'!I:I>=A3,IF('EP Data'!I:I<=B3,IF('EP Data'!D:D=$A$1,IF(LEFT('EP Data'!E:E,2)="OP",'EP Data'!I:I)))),'EP Data'!I:I),1))} to count unique instances of multiple parameters around a variable. This formula is extremely slow and does not work on a huge dataset.

Any good way of approaching this general problem would be greatly appreciated.

Thank you,