Count Unique with multiple criteria excluding duplicate

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
197
Office Version
  1. 2013
Platform
  1. Windows
Hello Friends,
Need your help to count the IDs based on multiple criteria. If you guys can help me to create a formula to update output section (H4 to K5)

Thank you as always :)

Book1
ABCDEFGHIJK
1IDProductLOBStatusCount unique IDs based on multiple criterias
266545523cardCCBSIActiveCardReceivables
366545523cardCCBSIActiveOutput --->ActiveInactiveActiveInactive
411223344receivablesCREActiveCCBSI1110
533445566cardCREActiveCRE2011
611223344cardCREActive
711223344receivablesCREInactive
866545523cardCCBSIInactive
911223344receivablesCCBSIActive
1033445566receivablesCREActive
1166545523receivablesCREInactive
Sheet1
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Maybe something like this.
This is an array formula and must be entered with CTRL-SHIFT-ENTER .
Also, I get a different answer for CRE in the Receivables.

Drag formula down and across.
Book1
ABCDEFGHIJK
1IDProductLOBStatusCount unique IDs based on multiple criterias
266545523cardCCBSIActiveCardCardReceivablesReceivables
366545523cardCCBSIActiveOutput --->ActiveInactiveActiveInactive
411223344receivablesCREActiveCCBSI1110
533445566cardCREActiveCRE2022
611223344cardCREActive
711223344receivablesCREInactive
866545523cardCCBSIInactive
911223344receivablesCCBSIActive
1033445566receivablesCREActive
1166545523receivablesCREInactive
Sheet1
Cell Formulas
RangeFormula
H4:K5H4=SUM(IF(FREQUENCY(IF($C$2:$C$11<>"",IF($C$2:$C$11=$G4,IF($D$2:$D$11=H$3,IF($B$2:$B$11=H$2,MATCH($A$2:$A$11,$A$2:$A$11,0))))),ROW($A$2:$A$11)-ROW($A$2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Maybe something like this.
This is an array formula and must be entered with CTRL-SHIFT-ENTER .
Also, I get a different answer for CRE in the Receivables.

Drag formula down and across.
Book1
ABCDEFGHIJK
1IDProductLOBStatusCount unique IDs based on multiple criterias
266545523cardCCBSIActiveCardCardReceivablesReceivables
366545523cardCCBSIActiveOutput --->ActiveInactiveActiveInactive
411223344receivablesCREActiveCCBSI1110
533445566cardCREActiveCRE2022
611223344cardCREActive
711223344receivablesCREInactive
866545523cardCCBSIInactive
911223344receivablesCCBSIActive
1033445566receivablesCREActive
1166545523receivablesCREInactive
Sheet1
Cell Formulas
RangeFormula
H4:K5H4=SUM(IF(FREQUENCY(IF($C$2:$C$11<>"",IF($C$2:$C$11=$G4,IF($D$2:$D$11=H$3,IF($B$2:$B$11=H$2,MATCH($A$2:$A$11,$A$2:$A$11,0))))),ROW($A$2:$A$11)-ROW($A$2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
This is awesome, thank you. But this formula is slowing down excel performance. Every time I apply filter in the raw data it starts calculating threads.
 
Upvote 0
Is there a different formula to this that can improve excel performance?
 
Upvote 0
Here is another option using a helper column you might try. My guess is that this will be just as slow and maybe slower if you have a large data set.

Book1
ABCDEFGHIJK
1IDProductLOBStatusHelperCount unique IDs based on multiple criterias
266545523cardCCBSIActive1CardCardReceivablesReceivables
366545523cardCCBSIActive2ActiveInactiveActiveInactive
411223344receivablesCREActive1CCBSI1110
533445566cardCREActive1CRE2022
611223344cardCREActive1
711223344receivablesCREInactive1
866545523cardCCBSIInactive1
911223344receivablesCCBSIActive1
1033445566receivablesCREActive1
1166545523receivablesCREInactive1
Sheet1
Cell Formulas
RangeFormula
H4:K5H4=SUMPRODUCT(($C$2:$C$11=$G4)*($D$2:$D$11=H$3)*($E$2:$E$11=1)*($B$2:$B$11=H$2))
E2:E11E2=SUMPRODUCT(($A$2:A2=A2)*($B$2:B2=B2)*($C$2:C2=C2)*($D$2:D2=D2))
 
Upvote 0
SUMPRODUCT can be very slow over large data sets. I have no idea how this would compare (also using a helper column which could be hidden) but you could give it a try.

23 11 05.xlsm
ABCDEFGHIJK
1IDProductLOBStatusHelper
266545523cardCCBSIActive66545523|card|CCBSI|ActiveCardCardReceivablesReceivables
366545523cardCCBSIActive ActiveInactiveActiveInactive
411223344receivablesCREActive11223344|receivables|CRE|ActiveCCBSI1110
533445566cardCREActive33445566|card|CRE|ActiveCRE2022
611223344cardCREActive11223344|card|CRE|Active
711223344receivablesCREInactive11223344|receivables|CRE|Inactive
866545523cardCCBSIInactive66545523|card|CCBSI|Inactive
911223344receivablesCCBSIActive11223344|receivables|CCBSI|Active
1033445566receivablesCREActive33445566|receivables|CRE|Active
1166545523receivablesCREInactive66545523|receivables|CRE|Inactive
Count
Cell Formulas
RangeFormula
H4:K5H4=COUNTIFS($E$2:$E$11,"*|"&H$2&"|"&$G4&"|"&H$3)
E2:E11E2=IF(ISNUMBER(MATCH(A2&"|"&B2&"|"&C2&"|"&D2,E$1:E1,0)),"",A2&"|"&B2&"|"&C2&"|"&D2)
 
Upvote 0

Forum statistics

Threads
1,215,182
Messages
6,123,517
Members
449,102
Latest member
admvlad

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