• 662K Members
• 10.5K Online
• 814K Conversations

## comparing cell values to determine which is highest, then returning the name assocaited with it

Highlighted
Occasional Contributor

# comparing cell values to determine which is highest, then returning the name assocaited with it

Okay, so I've exhausted everything I can find and I'm still nowhere on this. The problem is this:

Part 1:

The formula to look at both A2 and B2 to determine which is highest, then in C2 output the 'header' for the winner. In the example above, "Yellow" for C2, "Blue" for C3 etc. To add an additional twist, the minimum 'winner' would need to be above the number 1000. If below then return something like, "no winner"

I also require the opposite, which I guess would be simple to work out once the above is figured out, whereby it would display to the biggest loser, but this time with a maximum return value of 1000

Part 2

Now to add a twist of lemon to the cocktail.

Same as above, however, this time it takes a mean average of all entries in a row with a "1" associated with it to determine which is again the 'winner/loser'. So D2 would simply be the winner between B2 and C2, but D4 would be the winner between the average of B2 and B4, and C2 and C4.

--

I have looked high and low, and can't find anything on it. It may be due to not knowing the parlance which describes the issue properly, but the closest I can find is some kind of vlookup or indexing, which doesn't seem to get me there

Thank you in advance to anyone that can help; its driving me up the wall

17 Replies

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Both scenarios of part 1 are done and attached in sample file for your reference. Please let me know if it works as desired .

Please elaborate more the second part of your requirement, for example what criteria you need for D3, D5 or D6.

Thanks

Tauqeer

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

For such sample

for the first case formula could be

=IF(MAX(A2:B2)<1000, "no winner", INDEX(\$A\$1:\$B\$1,(B2>A2)+1))

for the second one

=IF( MAX(F2:G2)<MAX(AGGREGATE(14,6,1/(\$E\$2:\$E\$6=\$E2)*\$G\$2:\$G\$6,1),AGGREGATE(14,6,1/(\$E\$2:\$E\$6=\$E2)*\$F\$2:\$F\$6,1))+(MAX(F2:G2)<1000), "no winner", INDEX(F\$1:G\$1,(AGGREGATE(14,6,1/(\$E\$2:\$E\$6=\$E2)*\$G\$2:\$G\$6,1)>AGGREGATE(14,6,1/(\$E\$2:\$E\$6=\$E2)*\$F\$2:\$F\$6,1))+1))
Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Hi

Please take a look at attached file which hopefully covers both cases (part 1 and part 2).

File

Let me know if this solved the issue or if I misunderstood your requirement

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Hey, Thanks for taking the time to look at this, for me.

I'm not sure your solution is correct. I changed the blue to a lower value than the yellow, and it returned no winner each time, instead of yellow

As for part 2, it is essentially the same problem, however it is looking at an aggregate of numbers, rather than just one number to compare. To reword it, instead of 1,2 lets call them Q1, Q2, Q3, Q4 of a year for example. I want to look at what the average 'Blue' number was in say 'Q1' going back in time, and compare that against its 'Yellow' counterpart to determine which is higher/lower.

So in the image above, I've highlighted Q1 for the sake of ease. so in cell D1, it would just be the winner between B2 and C2, which is Blue (and loser in the opposite condition). when we get to cell D6, it would then be the mean average of B2 and B6 vs the mean average of C2 and C6. Then in cell D10, it would be the average of B2, B6 and B10, vs C2, C6, C10 ad nauseam.

Do let me know if that makes more sense, and thanks again for your time on this!

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Thank you for looking at this problem for me.

In your solution for part 2, there are two instances of no winners, when there is:

H2 would show yellow as the winner as being higher than blue 1183 vs 1001, and the same for H3

Do let me know if I need to expound on my explanation of the problem, and thanks again

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

In general, better if you attach your sample file to the post together with screenshorts - you'll save time for the people who are answering on generating new test file copying your data from the screen into Excel sheet.

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

When I misunderstood your logic. In second case I checked all pairs marked as 1 (or 2, etc.), found among them highest result and for this pair return the winner. All other "1" pairs are not winners.

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Still not sure I understood the issue, does attached file do the job?

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Hey, and thanks for helping me on this problem.

I think its almost correct, however, every other cell under E is empty?

Highlighted

Noted, Thanks
Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

i thought part 2 was only for rows which are marked with "1". But then it's the same for the rows with "2". Check out the new file and see if it works

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

As far as the first part is concerned it is showing 'no winner' in all cases because of the below condition that you mentioned in in your first post,

'the minimum 'winner' would need to be above the number 1000. If below then return something like, "no winner"

If you simply input 1001, it will show Yellow as winner

Thanks

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Couple observations. I changed the first set to below 1000 each, and yet yellow is showing as the winner still in part 2 rather than no winner. Also, how would the formula look to show the opposite, ie the lowest?

In application, I will be looking to put this across maybe 100 different inputs (blue, yellow, etc) and I'm essentially looking for the highest colour from 1000 and the lowest colour from 1000.

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Ah, I think there has been a misunderstanding. The winning entry so to speak must be above the 1000 mark to be the winner, but what its comparing against could very well be below 1000
Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

OK the 1000 rules also needs to be in part 2, I didn't know. Find attached the new version.

If this is anything close to the result you would like to have maybe you can try to do the finetuning of the formulare yourself

Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Hi,

Its still showing no winner if yellow is below 1000. I've looked at your formula, and to be honest, I don't know where to start to adjust it!
Highlighted

# Re: comparing cell values to determine which is highest, then returning the name assocaited with it

Hi @kemble999

To enhance the flavor of your cocktail, I added a red color in the attached file. The formula in D3 is:

=IF(MAX(A3:C3)>D\$1,
LOOKUP(2,1/(FREQUENCY(0,1/A3:C3)),A\$2:C\$2),
"None")

Conversely, the array formula (entered with Ctrl+Shift+Enter) in J3 is:

=IF(MAX(MMULT(TRANSPOSE(--(F\$3:F3=F3)),G\$3:I3))>J\$1,
LOOKUP(2,1/(FREQUENCY(0,1/MMULT(TRANSPOSE(--(F\$3:F3=F3)),G\$3:I3))),G\$2:I\$2),
"None")

Note that the values in K7:M14 were presented only for verification purposes. Thus, they are not referred to in the foregoing formula.

Cheers,