问题
I have some data in excel, I want to select unique values based on multiple criteria.
The data that I have in excel is
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.
回答1:
So if this is your data:
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.
回答2:
Another option would be to use a pivot-table with
Year filtered as as
>=2017
Name Values between
2
and6
Which yields the following result:
and then we simply count unique values (excluding blank cells
<>""
)
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 :)
来源:https://stackoverflow.com/questions/56059103/not-able-to-find-unique-values-in-excel