Count matches with two criteria

Osvaldo Palmeiro

Well-known Member
Joined
Feb 24, 2009
Messages
752
Office Version
  1. 365
Platform
  1. Windows
Hi all.
Please, I would like to count via formula the number of occurrences based on two criteria: same points AND same ages for each couple.
The formula should not refer to a specific value of points or a specific age, nor should refers to the cell rows that holds those data, but should adopt the equalities of points and ages as criteria.
Appreciate any help.
Thanks in advance.

Cópia de Cópia de Ranking x5 2.0-1 V2.xlsm
ABCDEFGHI
1name1name2pointsagecouplescount ocurrences (expected results)
2JohnAnneany points xxany age aaJohnAnne2
3MikeAnneany points wwany ageMikeMary3
4JohnMaryany pointsany age
5MikeMaryany points yyany age mm
6JohnAnneany points xxany age aa
7MikeMaryany pointsany age
8JohnAnneany points bbany age
9MikeMaryany points yyany age mm
10JohnMaryany pointsany age
11MikeMaryany points yyany age mm
12
Planilha1
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Could you explain why row 8 is not yellow and row 7 is not blue?
 
Upvote 0
Hi, jason.
Thanks for reply.

Row 8 is not yellow because C8 doesn't match C2 and C6, also D8 doesn't match D2 and D6.

Row 7 is not blue because C7 doesn't match C5, C9 and C11, also D7 doesn't match D5, D9 and D11.

Hope it's clearer now.

Thanks again.
 
Upvote 0
So using the yellow as an example, what is the criteria to determine that 'Points xx' and 'Age aa' are the correct entries to count?

If row 8 is not counted because it doesn't match the others then there needs to be a reason why the others are the correct ones to count, otherwise it will not be possible to isolate them.
 
Upvote 0
The criteria is the equality between points and between ages and not the values themselves. That is, for the yellow couple we should count how many times there are equality between points and between ages.
Something like If And(A:A = F2, B:B=G2) then count duplicates in column C if those duplicates rows are duplicates in column D too.

I've got it via macro, applying Filter using each couple as criteria and then counting duplicates in column C & duplicates in column D same rows.

But I would prefer a solution via formula, if possible.

Thanks
 
Upvote 0
Ok, I'm kind of following. It's often easier to understand what you want than it is to explain it to someone else.

With a slight change to your example, should this count as 2 for yellow and 2 for green, or 4 for the John / Anne combination (or something different)?
Book1
ABCD
1name1name2pointsage
2JohnAnneany points xxany age aa
3MikeAnneany points wwany age
4JohnMaryany pointsany age
5MikeMaryany points yyany age mm
6JohnAnneany points xxany age aa
7MikeMaryany pointsany age
8JohnAnneany points bbany age yy
9MikeMaryany points yyany age mm
10JohnAnneany points bbany age yy
11MikeMaryany points yyany age mm
Sheet2
 
Upvote 0
I apologize for not being able to accurately pass you the criteria and for my screen shot not being clear enough..

Yes, the desired result would be 4 for that combination.

Many, many thanks for now.
 
Upvote 0
This looks like it works correctly, I've tested with your original example and my edited version with both returning the correct expected results.
Book1
ABCDEFGH
1name1name2pointsagecouplescount ocurrences
2JohnAnneany points xxany age aaJohnAnne2
3MikeAnneany points wwany ageMikeMary3
4JohnMaryany pointsany age
5MikeMaryany points yyany age mm
6JohnAnneany points xxany age aa
7MikeMaryany pointsany age
8JohnAnneany points bbany age
9MikeMaryany points yyany age mm
10JohnMaryany pointsany age
11MikeMaryany points yyany age mm
Sheet1
Cell Formulas
RangeFormula
H2:H3H2=ROWS(FILTER($A$2:$B$11,($A$2:$A$11=F2)*($B$2:$B$11=G2)))-IFERROR(ROWS(UNIQUE(FILTER($A$2:$D$11,($A$2:$A$11=F2)*($B$2:$B$11=G2)),0,1)),0)
 
Upvote 0
Solution
Hey, jason.

It works nicely.

No words to thank you enough. Amazing.

Many, many, many thanks. Have a nice week.
 
Upvote 0

Forum statistics

Threads
1,215,415
Messages
6,124,768
Members
449,187
Latest member
hermansoa

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