问题
I would like to be able to find the most common value given a certain criteria in an adjacent column. For example:
>**ROW A** ----- **ROW B**
>Blue ---------- Jason
>Blue ---------- Jason
>Blue ---------- Charles
>Red ---------- Alfred
>Red ---------- Alfred
>Red ---------- Barry
>Green --------- Barry
I would like a formula that could look like the following
if(X=Row_A_Value,Mode of X)
For instance if "BLUE" then the output would be "JASON". If "RED" the output would be "ALFRED"
I've tried using Index(Mode(Match)) without any luck...
Thanks for your help!
回答1:
Not exactly the prettiest formula, but this array formula works: (line break added for readability)
= INDEX(B1:B7,MATCH(MAX(COUNTIFS(A1:A7,"Blue",B1:B7,B1:B7)),
COUNTIFS(A1:A7,"Blue",B1:B7,B1:B7),0))
There probably is a more efficient way but this is just the first one I could think of.
Obviously, just replace the two instances of "Blue"
in the formula above with "Red"
in order to search for red instead.
Note this is an array formula, so you must press Ctrl+Shift+Enter after typing this formula rather than just Enter.
See below, working example.
来源:https://stackoverflow.com/questions/48629972/finding-mode-based-of-conditional-criteria