Finding MAX value with criteria list [Solved/Closed]

RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 17, 2016 at 09:31 PM - Latest reply: fdibbins 33 Posts Sunday June 19, 2016Registration dateContributorStatus November 20, 2016 Last seen
- Jun 20, 2016 at 11:14 PM
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
See more 

11 replies

vcoolio 1159 Posts Thursday July 24, 2014Registration dateModeratorStatus March 28, 2018 Last seen - Jun 19, 2016 at 04:00 AM
0
Helpful
1
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.
RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 19, 2016 at 10:52 AM
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.
fdibbins 33 Posts Sunday June 19, 2016Registration dateContributorStatus November 20, 2016 Last seen - Jun 19, 2016 at 11:39 PM
0
Helpful
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
RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 19, 2016 at 11:48 PM
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.
fdibbins 33 Posts Sunday June 19, 2016Registration dateContributorStatus November 20, 2016 Last seen - Jun 20, 2016 at 02:10 AM
0
Helpful
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()
RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 20, 2016 at 11:01 AM
"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?
vcoolio 1159 Posts Thursday July 24, 2014Registration dateModeratorStatus March 28, 2018 Last seen - Jun 20, 2016 at 03:18 AM
0
Helpful
1
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.
fdibbins 33 Posts Sunday June 19, 2016Registration dateContributorStatus November 20, 2016 Last seen - Jun 20, 2016 at 11:14 PM
Thanks for the invite, hope I can be of help here :)
TrowaD 2348 Posts Sunday September 12, 2010Registration dateModeratorStatus April 24, 2018 Last seen - Jun 20, 2016 at 11:20 AM
0
Helpful
2
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
RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 20, 2016 at 11:31 AM
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.
RayH 122 Posts Tuesday August 31, 2010Registration dateContributorStatus June 20, 2016 Last seen - Jun 20, 2016 at 01:23 PM
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))