Use LARGE function with non-numerical data

Rainmanne

Board Regular
Joined
Mar 10, 2016
Messages
132
Office Version
  1. 2013
Platform
  1. Windows
I need to pick up the lowest value out of two highest out of three. So I have now 3 non-numerical values, which correspond to numerical values and I need to choose the lowest out of the two highest. I figured out that I can use LARGE to pick the 2 highest values and then use MIN to pick up the lowest out of them. However, LARGE takes an array and I cannot figure out how to use non-numerical array with LARGE.

I have created a Scale sheet in the workbook, which sets the relationship between various sets of non-numerical grades and assigns numerical value to each of them. And I basically use INDEX/MATCH to convert non-numerical into numerical if I need to manipulate them and then convert back to non-numerical.

Please see below the setup I have:

Scale sheet
Non-NumNumGrade Set 1Grade Set 2/3
25
124AUp+
1a23BUp
1b22CUp-

Calc sheet
ItemGrade Set 1Grade Set 2Grade Set 3Set 1 in Non-NumSet 2 in Non-NumSet 3 in Non-NumLowest grade
XYZAUpUp-11a1b? (should be 1a)

So I put grades from sets 1, 2 and 3 in columns 2-4 and convert them into unified Non-Num grades in cols 5-7. In column 8 I want to display the lowest grade of two highest in cols 5-7. So I tried

Excel Formula:
=MIN(INDEX(Scale!$A$1:$D$26,MATCH(LARGE(J6:L6,1),Scale!$A$1:$A$26,0),2),IFERROR(INDEX(Scale!$A$1:$D$26,MATCH(LARGE(J6:L6,2),Scale!$A$1:$A$26,0),2),25))

but t doesn't work because content of the arrays for the LARGE function are non-numeric. I can of course create a three separate columns, convert non-numericals into numericals but I would like to avoid it and rather do it in col 8. Sorry if it's all presented in a confusing way.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Large is a numeric function, it will never work with anything non-numeric, the same applies to Min and many other functions.

The best thing that you could do is list all grades in ascending order (which I assume you have done in A1:A26) then use something like
Excel Formula:
=INDEX(Scale!$A$1:$A$26,LARGE(MATCH(J6:L6,Scale!$A$1:$A$26,0),2))
 
Upvote 0
Large is a numeric function, it will never work with anything non-numeric, the same applies to Min and many other functions.

The best thing that you could do is list all grades in ascending order (which I assume you have done in A1:A26) then use something like =INDEX(Scale!$A$1:$A$26,LARGE(MATCH(J6:L6,Scale!$A$1:$A$26,0),2))
Thanks a lot, but unfortunately it returns #VALUE!. I tried it as an array formula but it returns a wrong value. I cannot figure out how to convert a range of non-numerical values into numerical for LARGE in an array formula. For example, I tired just
Excel Formula:
{=MATCH(J10:L10,Scale!$A$1:$A$26,0)}
and it returns a number 6, while the values in J10:L10 correspond to 21, 17 and 7. And if I add LARGE:
Excel Formula:
{=LARGE(MATCH(J10:L10,Scale!$A$1:$A$26,0),1)}
it returns 20

I cannot understand how it works. Array functions always baffled me.
 
Upvote 0
I tried it as an array formula but it returns a wrong value.
Then it sounds like it's the right formula but might need a bit of adjustment. What happens if you test it on several rows of data, can you see any pattern to the wrong results, for example is it always 1 away from where it should be?
 
Upvote 0
Then it sounds like it's the right formula but might need a bit of adjustment. What happens if you test it on several rows of data, can you see any pattern to the wrong results, for example is it always 1 away from where it should be?
I have finally managed to install XL2BB. So posting the range.

mre.xlsx
ABCDEFGHIJ
1ItemNon-NumGrade Set 1Grade Set 2Grade Set 3Set 1 in Non-NumSet 2 in Non-NumSet 3 in Non-NumLowest gradeShould Be
2Item1AMid+Up131a101a
3Item2BMidUp-1a3a1b91b
4Item3CMid-LUP+1b3b282
5Item4DDown+LUP242a72a
6Item5EDownLUP-2a4a2b6b2b
7Item6FDown-Down+2b4b45a4
8Item7GLDown+Down354a54a
9Item8LLDownDown-4b5a4b4b4b
10Item9MUp+LDown+5154a5
11Item10   
12Item11   
13Item12   
14Item13   
15Item14   
16Item15   
17Item16   
18Item17   
19Item18   
20Item19   
21Item20   
22Item21   
23Right-click and insert a new row here and fill down columns A-K
Rating
Cell Formulas
RangeFormula
F2:F10F2=IF(ISBLANK(C2),"",INDEX(Scale!$A$1:$D$26,MATCH(C2,Scale!$C$1:$C$26,0),MATCH($B$1,Scale!$A$1:$D$1,0)))
G2:H10G2=IF(ISBLANK(D2),"",INDEX(Scale!$A$1:$D$26,MATCH(D2,Scale!$D$1:$D$26,0),MATCH($B$1,Scale!$A$1:$D$1,0)))
I2:I10I2=INDEX(Scale!$A$2:$D$26,MATCH(MIN(LARGE(MATCH(F2:H2,Scale!$A$2:$A$26,0),1),LARGE(MATCH(F2:H2,Scale!$A$2:$A$26,0),2)),Scale!$B$2:$B$26,0),1)
F11:F22F11=IF(ISBLANK(C11),"",INDEX(Scale!$A$1:$D$26,MATCH(C11,Scale!$C$1:$C$26,0),MATCH(#REF!,Scale!$A$1:$D$1,0)))
G11:H22G11=IF(ISBLANK(D11),"",INDEX(Scale!$A$1:$D$26,MATCH(D11,Scale!$D$1:$D$26,0),MATCH(#REF!,Scale!$A$1:$D$1,0)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
To post a second sheet you can go back to excel and copy it with XL2BB the same way as you did for the first one, then paste it below the BB code for the first sheet.

From the example provided, the only reason that I can see for the wrong results is that you are using the wrong formula. The formula in your sheet is not the one that I suggested.
 
Upvote 0
To post a second sheet you can go back to excel and copy it with XL2BB the same way as you did for the first one, then paste it below the BB code for the first sheet.

From the example provided, the only reason that I can see for the wrong results is that you are using the wrong formula. The formula in your sheet is not the one that I suggested.
Sorry I have messed up the formula. It works now! I was a bit stupid because the condition I had was "the lowest of the two highest values" and I only now realised that it's the same as "the second largest" as your formula does.

The only issue I have now is that the formula only works, when all three values are present. If there are only two or one value, it returns #N/A. I guess it's because a blank cell with a formula does not have a match in the Scale table. I don't know how to edit a published post so I am posting the Scale sheet here in case it's needed.

mre.xlsx
ABCD
1Non-NumNumGrade Set 1Grade Set 2/3
2025
3124AUp+
41a23BUp
51b22CUp-
6221DLUP+
72a20ELUP
82b19FLUP-
9318GMid+
103a17HMid
113b16IMid-
12415JDown+
134a14KDown
144b13LDown-
15512MLDown+
165a11NALDown
175b10OLDown-
1869PBT+
196a8QBT
206b7RBT-
2176SBT--
2285S-XLL
2394NANA
24103NANA
25112NANA
26NR1NANA
Scale
 
Upvote 0
The only issue I have now is that the formula only works, when all three values are present. If there are only two or one value, it returns #N/A.
What would you expect if there is only one value in the row, should it show that as the result or just show nothing?

This will work as long as there are two or more values that can be matched, but will need some additional changes depending on the requirement for a single value.
Excel Formula:
=INDEX(Scale!$A$1:$A$26,AGGREGATE(14,6,MATCH(J6:L6,Scale!$A$1:$A$26,0),2))
 
Upvote 0
What would you expect if there is only one value in the row, should it show that as the result or just show nothing?

This will work as long as there are two or more values that can be matched, but will need some additional changes depending on the requirement for a single value.
Excel Formula:
=INDEX(Scale!$A$1:$A$26,AGGREGATE(14,6,MATCH(J6:L6,Scale!$A$1:$A$26,0),2))
If there's only one value, it should be displayed in the results. If the whole row is blank then it should show an empty cell, which I can probably do with IFNA function.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top