Distinct Count a Column Based on Criteria from Other Columns

shellp

Board Regular
Joined
Jul 7, 2010
Messages
194
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
FyearMISRescodeTreating_HospitalHCNVisits
2018Dialysis_Home0240Grey-Sloane5555555555
1​
2018Dialysis_Home0240Grey-Sloane5555555555
1​
2018Dialysis_Other0200Grey-Sloane4444444444
1​
2018Dialysis_Other0232Sunshine Hospital5555555555
1​
2018Dialysis_Other0240Grey-Sloane5555555555
1​
2019Dialysis_Home0200Sunshine Hospital4444444444
1​
2019Dialysis_Home0232Grey-Sloane5555555555
1​
2019Dialysis_Home0240Grey-Sloane5555555555
1​
2019Dialysis_Other0200Grey-Sloane5555555555
1​
2019Dialysis_Other0240Sunshine Hospital5555555555
1​

For the table above, I'd like to find distinct count of the HCN field (unique identifier for patient) with the filters of fyear, MIS, rescode and treating hospital. So for the above, if the fiscal year is 2018, the MIS is dialysis_home, the rescode is 0240 and the treating hospital is Grey-Sloane, there should be 1 distinct patient.

I don't know how to link other posts but in an August 17, 2020 post about distinct counts based on patient IDs, Eric W responded with =SUM(SIGN(FREQUENCY(IF(C2:C6=G2,IF(D2:D6=H2,E2:E6)),E2:E6))) where E was the patient identifier. This works for my example if the HCN is a number field but in my case it is not so can Eric W's response be edited for use with text? Thanks for any and all assistance.
 
Sorry guys, the array plus the size of the dataset is causing huge delays...is there any other way to do this? Thanks.
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Thanks for updating your profile :)
Unfortunately, I don't know of any formula that would be faster & would work with 2010.
 
Upvote 0
It is working Fine

Book1
ABCDEFG
1FyearMISRescodeTreating_HospitalHCNVisits
22018Dialysis_Home240Grey-Sloaneabc12
32018Dialysis_Home240Grey-Sloanedef12
42018Dialysis_Home240Grey-Sloaneabc12
52018Dialysis_Other232Sunshine Hospitalabc12
62018Dialysis_Other232Sunshine Hospitaldef12
72018Dialysis_Home240Grey-Sloaneabc12
82019Dialysis_Home232Grey-Sloaneabc11
92019Dialysis_Home240Grey-Sloaneabc11
102019Dialysis_Other200Grey-Sloaneabc11
112019Dialysis_Other240Sunshine Hospitalabc11
Sheet1
Cell Formulas
RangeFormula
G2:G11G2=SUM(IFERROR(FREQUENCY(IFERROR(MATCH(MATCH(IF(($A$2:$A$11=A2)*($B$2:$B$11=B2)*($C$2:$C$11=C2)*($D$2:$D$11=D2),$E$2:$E$11),$E$2:$E$11,0),ROW($E$2:$E$11)-ROW($E$2)+1,0),FALSE),ROW($E$2:$E$11)-ROW($E$2)+1)^0,0))
 
Upvote 0
So if we use Pivot Table to count Unique and then Vlookup with all critieria using "&" it should work fast
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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