Count If Distinct Values based on Criteria

Tashat

Board Regular
Joined
Jan 12, 2005
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Hi All

Please can you help me with a formula? I am trying to count the number of distinct values based on a criteria. In this case, I want to count how many pieces of fruit Jennifer had, but I don't want to count the second fruit if it was repeated. e.g. Jennifer had two apples and two oranges, but I only want to count the first of each of these. So she had overall, 4 different pieces of fruit. Thanks in advance as always. Natasha

Book3
ABCDE
1PersonFruit
2JenniferAppleJennifer4
3AdamPlum
4JenniferApple
5AdamApple
6GeoffBanana
7JenniferOrange
8BarneyBanana
9JenniferPlum
10AmyKiwi
11SamCherry
12JackKiwi
13NatashaPlum
14AlPlum
15JenniferOrange
16AlBanana
17JenniferBanana
Sheet1
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Excel Formula:
=SUM(IF(FREQUENCY(IF(A$2:A$17=D2,MATCH(B$2:B$17,B$2:B$17,0)),ROW(B$2:B$17)-ROW(B$2)+1),1))

Array formula CTL+SHT+ENT
 
Upvote 0
With 365 you can try this.

21 08 12.xlsm
ABCDE
1PersonFruit
2JenniferAppleJennifer4
3AdamPlum
4JenniferApple
5AdamApple
6GeoffBanana
7JenniferOrange
8BarneyBanana
9JenniferPlum
10AmyKiwi
11SamCherry
12JackKiwi
13NatashaPlum
14AlPlum
15JenniferOrange
16AlBanana
17JenniferBanana
Count
Cell Formulas
RangeFormula
E2E2=ROWS(UNIQUE(FILTER(B2:B17,A2:A17=D2)))
 
Upvote 0
Solution
With 365 you can try this.

21 08 12.xlsm
ABCDE
1PersonFruit
2JenniferAppleJennifer4
3AdamPlum
4JenniferApple
5AdamApple
6GeoffBanana
7JenniferOrange
8BarneyBanana
9JenniferPlum
10AmyKiwi
11SamCherry
12JackKiwi
13NatashaPlum
14AlPlum
15JenniferOrange
16AlBanana
17JenniferBanana
Count
Cell Formulas
RangeFormula
E2E2=ROWS(UNIQUE(FILTER(B2:B17,A2:A17=D2)))
Hi Peter_SSs - thank you so much. I've used this formula and it works perfectly :-)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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