Count Unique values w

MUSTAFA20

New Member
Joined
Aug 4, 2009
Messages
4
Hi every one , I have the following Table, what I need to do is to count the No. of uniqe cases considering both column, when Ref & Sub ref match it is a unique case. for the below example, (Ahmed 6 ) is repeated in three rows but should be counted as 1, (Mourad 11) is 1, (Saleem 5) is one, (Ahmed 7) is one therefore I want to get a total of 4.
ReferenceSub reference
Ahmed6
Mourad11
Ahmed6
Ahmed6
Ahmed7
Saleem5
Saleem5
Count of Unique cases??

<tbody>
</tbody>

In the table I have there are other data and other formulas therefore data filter and remove duplicates would not work, I need to use a formula for this.

I appreciate your help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Assuming your data is in the range A1:B7, the formula in C1:

=SUMPRODUCT((1/COUNTIFS(A1:A7,A1:A7,B1:B7,B1:B7)))
 
Upvote 0
In B9 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-(A2:A8=""),IF(ISNUMBER(B2:B8),MATCH(A2:A8&"|"&B2:B8,A2:A8&"|"&B2:B8,0))),ROW(A2:A8)-ROW(A2)+1),1))

Since the sub references are just numbers, the following would suit the objective as well...

Control+shift+enter:

=SUM(IF(FREQUENCY(IF(1-(A2:A8=""),IF(ISNUMBER(B2:B8),B2:B8)),B2:B8),1))

Note that the FREQUENCY formulas are faster for this job than the equivalent COUNTIF(S) formulas.
 
Upvote 0
Assuming your data is in the range A1:B7, the formula in C1:

=SUMPRODUCT((1/COUNTIFS(A1:A7,A1:A7,B1:B7,B1:B7)))
Thank you for your reply. Just one more thing please,
As you assumed, Data is from A1:B7 If we assumed there is a third column C1:C7 were C1,C2,C3 & C6 have (Mustafa), C4,C5, & C7 have (Amer).

how would I amend the formula to return unique values corresponding to each teacher.

ABC
1StudentClassTeacher
2Ahmed6Mustafa
3Mourad11Mustafa
4Ahmed6Mustafa
5Ahmed6Amer
6Ahmed7Amer
7Saleem5Mustafa
8Saleem5Amer
9
10TeacherNo. of unique cases
11Amer?
12Mustafa?

<tbody>
</tbody>
<table border="0" cellpadding="0" cellspacing="0" verdana,="" arial,="" tahoma,="" calibri,="" geneva,="" sans-serif;"="" style="width: "><colgroup><col><col><col span="px"2""></colgroup><tbody></tbody></table>

Thanks for the help again :biggrin:
 
Last edited:
Upvote 0
In B9 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-(A2:A8=""),IF(ISNUMBER(B2:B8),MATCH(A2:A8&"|"&B2:B8,A2:A8&"|"&B2:B8,0))),ROW(A2:A8)-ROW(A2)+1),1))

Since the sub references are just numbers, the following would suit the objective as well...

Control+shift+enter:

=SUM(IF(FREQUENCY(IF(1-(A2:A8=""),IF(ISNUMBER(B2:B8),B2:B8)),B2:B8),1))

Note that the FREQUENCY formulas are faster for this job than the equivalent COUNTIF(S) formulas.

Thank you. Although this would take more time for me to comprehend, I am new to frequency functions.

To complete my case I added one more assumption that I missed to mention at first place. I have added the scenario in my last reply. I could not do it using the normal ways i know, like sumif or countif functions. .

Thanks again.
 
Upvote 0
Thank you. Although this would take more time for me to comprehend, I am new to frequency functions.

To complete my case I added one more assumption that I missed to mention at first place. I have added the scenario in my last reply. I could not do it using the normal ways i know, like sumif or countif functions. .

Thanks again.

StudentClassTeacher
Ahmed6Mustafa
Mourad11Mustafa
Ahmed6Mustafa
Ahmed6Amer
Ahmed7Amer
Saleem5Mustafa
Saleem5Amer
TeacherNo. of unique cases
Amer3
Mustafa3

<tbody>
</tbody>

In B11 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-($A$2:$A$8=""),IF(ISNUMBER($B$2:$B$8),IF($C$2:$C$8=$A$11,$B$2:$B$8))),$B$2:$B$8),1))

1. On FREQUENCY function for counting unique items...

http://www.mrexcel.com/forum/excel-...ing-sum-if-frequency-match-2.html#post3156949

2. On COUNTIF(S) function for counting unique items...

http://www.mrexcel.com/forum/excel-questions/16682-count-unique-entries.html
http://www.mrexcel.com/forum/excel-questions/70835-count-distinct-function.html#post342159

3. On performance...

http://www.mrexcel.com/forum/excel-questions/292473-performance-formulas-unique-count.html
 
Upvote 0
StudentClassTeacher
Ahmed6Mustafa
Mourad11Mustafa
Ahmed6Mustafa
Ahmed6Amer
Ahmed7Amer
Saleem5Mustafa
Saleem5Amer
TeacherNo. of unique cases
Amer3
Mustafa3

<tbody>
</tbody>

In B11 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-($A$2:$A$8=""),IF(ISNUMBER($B$2:$B$8),IF($C$2:$C$8=$A$11,$B$2:$B$8))),$B$2:$B$8),1))

1. On FREQUENCY function for counting unique items...

http://www.mrexcel.com/forum/excel-...ing-sum-if-frequency-match-2.html#post3156949

2. On COUNTIF(S) function for counting unique items...

http://www.mrexcel.com/forum/excel-questions/16682-count-unique-entries.html
http://www.mrexcel.com/forum/excel-questions/70835-count-distinct-function.html#post342159

3. On performance...

http://www.mrexcel.com/forum/excel-questions/292473-performance-formulas-unique-count.html


Thanks Alot
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

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