3
votes

I have some data in excel, I want to select unique values based on multiple criteria.

The data that I have in excel is

enter image description here


Name Medals Year

  • A 2 2017
  • B 3 2018
  • C 5 2018
  • A 1 2016
  • C 4 2017
  • B 7 2018
  • A 1 2017
  • D 4 2016

I want to get the count of unique names who got medals >2 and <6 and year is 2017 or 2018.

So the result that I should get is 2 as B and C satisfy the criteria.

I have searched in internet about his and I got some formula using SUMPRODUCT and COUNTIFS, the formula used is

=SUMPRODUCT(1/COUNTIFS(A2:A9,A2:A9,B2:B9,">2",B2:B9,"<6",C2:C9,">2016",C2:C9,"<2019" ))

But I am getting error in this case.

Please suggest me how can I get the desired count. Thanks in advance!!

Note: This data is excerpted from huge data.

2

2 Answers

3
votes

So if this is your data:

enter image description here

The formula used in E9:

{=SUM(--(FREQUENCY(IF((B2:B9>2)*(B2:B9<6)*(C2:C9>2016)*(C2:C9<2019),MATCH(A2:A9,A2:A9,0)),ROW(A2:A9)-ROW(A2)+1)>0))}

See here for more in depth explaination.

0
votes

Another option would be to use a with

  • Year filtered as as >=2017

    enter image description here

  • Name Values between 2 and 6

    enter image description here

  • Which yields the following result:

    enter image description here

  • and then we simply count unique values (excluding blank cells <>"")

enter image description here

Would say this formula is a bit more user-friendly and makes for a better visual representation of the data, but if you just want a formula, then absolutely go for @JvdV's solution :)