Count If Distinct Values based on Criteria

Tashat

Board Regular
Joined
Jan 12, 2005
Messages
135
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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