Forum Discussion
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
- TwifooSilver Contributor
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,
- PascalKTeamIron Contributor
Hi
Please take a look at attached file which hopefully covers both cases (part 1 and part 2).
https://kteamch-my.sharepoint.com/:x:/g/personal/pascal_kiefer_kteam_ch/ERyix6L1a2BOr74NSmaZxjABlX0mzT_DpgSZEaF2uCcF9A?e=0ufQlc&Download=1
Let me know if this solved the issue or if I misunderstood your requirement
- kemble999Copper Contributor
Hey, and thanks for helping me on this problem.
I think its almost correct, however, every other cell under E is empty?
- PascalKTeamIron Contributor
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
- SergeiBaklanDiamond Contributor
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))
- kemble999Copper Contributor
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
- PascalKTeamIron Contributor
- tauqeeracmaIron Contributor
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
- kemble999Copper Contributor
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!
- tauqeeracmaIron Contributor
Hi kemble999
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