Finding MAX value with criteria list [Solved/Closed]

Report
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
-
Posts
33
Registration date
Sunday June 19, 2016
Status
Contributor
Last seen
November 20, 2016
-
Hello Chaps

I don't often ask for help here but this one has stumped me.

For a dashboard of sorts...
I have a list of values in column S.
Each of these has a status value in column C.

I need to find the maximum value in column S where the status matches one in a list of statuses.
The table of valid status values is in A2:A6

So something like "=(MAX(IF(C2:C111=ValueOnStatusTable,S2:S200)))
This would work if the StatusTable was only 1 cell and matched only 1 value


A C S
X M 5
M M 8
1 1 10
2 L 13
A A 8
A 5
X 3
K 1


So, in this case the value return would 10 as its status of M is in the list
The value of 13 is not returned as its status value of L is NOT in the list

Likewise for finding the MIN value.
In that case 3 would be returned and not 1 as X is valid and K is not.

Thanks
Ray

5 replies

Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
230
Hey Ray,

I'm just about to head off into the sunset but I was thinking that perhaps you could use the INDEX/MATCH function wrapped in the MAX function. Something like:-

=MAX(INDEX($C$1:$C$8,MATCH(A6,$B$1:B$8,0)))

assuming the values are in Columns A, B, & C.

If there isn't a matching value, it should return N/A in the column in which you place the formula. But I'm not sure if it could handle and give the right return if there is a value in the first column with two matches in the second column (such as the value "M").

Have a fiddle with it. You never know.

Formulae are not a strong point with me so where is Mazzaropi when you need him?!!?

I'm off. See ya.

Cheerio,
vcoolio.
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
24
Hey VC,
Thanks for the reply.
I think the solution you gave was one of the many variants I tried already.
It does return a value but doesn't take the whole valid status table into account and returns just the first instance of the status.

Bear in mind that it should return the MAX value of all of those statuses not individually.

I'd prefer a Maserati but I'd settle for Mazzaropi right now.
Posts
33
Registration date
Sunday June 19, 2016
Status
Contributor
Last seen
November 20, 2016
1
=(MAX(IF(C2:C111=ValueOnStatusTable,S2:S200)))
that is an ARRAY formula and needs to be entered using CTRL SHIFT ENTER, not just enter

=MAX(INDEX($C$1:$C$8,MATCH(A6,$B$1:B$8,0)))
Dont think this will work. INDEX/MATCH will return 1 value, so there will be nothing for MAX to work on.

The MAX/IF should work though
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
24
Hi fdibbins,

Yeah, I tried that too.
What I would I put in place of ValueOnStatusTable though? Using the range of the table I get #N/A indicating that it cant find a value??

Both the Status column (C) and the ValidStatus range are formatted as Text. Sometimes this causes a problem when they are different.
Posts
33
Registration date
Sunday June 19, 2016
Status
Contributor
Last seen
November 20, 2016
1
If the range you are trying to find the max of, is formatted as text, that is what is causing the problem - you cannot find the max of text...which is greater, blue or green?

You will need to convert those text "values" back to numbers 1st

hmm or maybe try using SUMPRODUCT()
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
24
"Both the Status column (C) and the ValidStatus range are formatted as Text. "

The value I am trying to MAX is formatted as "General"

Given this scenario, how do I pick out those values to SUMPRODUCT with?
Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
230
Hi Ford,

Welcome to CCM. Glad to see you here.

I see your logic as I'm sure that Ray can. It is a tricky one though!

Over to Ray...........

Thanks Ford.

Cheerio,
vcoolio.
Posts
33
Registration date
Sunday June 19, 2016
Status
Contributor
Last seen
November 20, 2016
1
Thanks for the invite, hope I can be of help here :)
Posts
2757
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
June 8, 2021
462
Hey guys,

Try reserving an extra column for this formula:
=IF(ISERROR(VLOOKUP(C2,$A$2:$A$6,1,0)),0,1)

I placed this in column T, but you can use any column, which you can then hide or place out of sight.

Then use this formula to get your answer:
=MAX((T2:T9=1)*S2:S9)
This is an array formula; confirm with Ctrl+Shift+Enter.

Best regards,
Trowa
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
24
Thanks TrowaD

That works. I was hoping not to use a helper column though but I'll take what I can get at this stage.
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
24
Those wanting to use this for MIN you have to wrap this in an IF to check for ZERO

=MIN(IF(($T2:$T9=1)*$S2:$S9>0,$S2:$S9))

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!