Count without duplicates

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I've a situation like the following:

column f column g
A ONE
A ONE
A TWO
A THREE
A THREE
B ONE
B ONE
B ONE
B TWO
A FOUR
A FOUR
A FOUR
A FOUR
A FIVE

I need a formula that counts how many differents values in column g for the value A in column f (in the example 5) and how many different values in column g for the value B in column f (in the example 2).

Thank you.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try


F
G
H
I
J
1
CountUnique​
2
A​
ONE​
A​
5​
3
A​
ONE​
B​
2​
4
A​
TWO​
5
A​
THREE​
6
A​
THREE​
7
B​
ONE​
8
B​
ONE​
9
B​
ONE​
10
B​
TWO​
11
A​
FOUR​
12
A​
FOUR​
13
A​
FOUR​
14
A​
FOUR​
15
A​
FIVE​

Array formula in J2 copied down
=SUM(IF(FREQUENCY(IF(F$2:F$15=I2,MATCH(G$2:G$15,G$2:G$15,0)),ROW(G$2:G$15)-ROW(G$2)+1),1))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0
Many thanks for the support: it works perfectly well.

Just add a constraint, if possible: to exclude the rows with value 0 in column h

column f column g column h
A ONE 7
A ONE 5
A TWO 0
A THREE 4
A THREE 2
B ONE 3
B ONE 0
B ONE 5
B TWO 6
A FOUR 0
A FOUR 2
A FOUR 4
A FOUR 3
A FIVE 2
 
Upvote 0
Maybe...


F
G
H
I
J
K
1
CountUnique​
2
A​
ONE​
7​
A​
4​
3
A​
ONE​
5​
B​
2​
4
A​
TWO​
0​
5
A​
THREE​
4​
6
A​
THREE​
2​
7
B​
ONE​
3​
8
B​
ONE​
0​
9
B​
ONE​
5​
10
B​
TWO​
6​
11
A​
FOUR​
0​
12
A​
FOUR​
2​
13
A​
FOUR​
4​
14
A​
FOUR​
3​
15
A​
FIVE​
2​

Array formula in K2
=SUM(IF(FREQUENCY(IF(F$2:F$15=J2,IF(H$2:H$15<>0,MATCH(G$2:G$15,G$2:G$15,0))),ROW(G$2:G$15)-ROW(G$2)+1),1))
Ctrl+Shift+Enter

M.
 
Upvote 0
Maybe...


F
G
H
I
J
K
1
CountUnique​
2
A​
ONE​
7​
A​
4​
3
A​
ONE​
5​
B​
2​
4
A​
TWO​
0​
5
A​
THREE​
4​
6
A​
THREE​
2​
7
B​
ONE​
3​
8
B​
ONE​
0​
9
B​
ONE​
5​
10
B​
TWO​
6​
11
A​
FOUR​
0​
12
A​
FOUR​
2​
13
A​
FOUR​
4​
14
A​
FOUR​
3​
15
A​
FIVE​
2​

Array formula in K2
=SUM(IF(FREQUENCY(IF(F$2:F$15=J2,IF(H$2:H$15<>0,MATCH(G$2:G$15,G$2:G$15,0))),ROW(G$2:G$15)-ROW(G$2)+1),1))
Ctrl+Shift+Enter

M.

Thank's: until today, it seems ok.

Now, I'm going to study the structure of the formula.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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