exceloffice365xlookup

XLOOKUP finding ranks for scores ignoring place values, returning wrong rank


I use xlookup all the time, so this is absolutely stumping me. Using a simple XLOOKUP formula to compare a list of values and find the resulting rank from a list of ranks. If I ONLY compare the score column, the ranks come in correctly. However, I need to run this dynamically across several contracts at once, so I definitely need to use the "[criteria1]&[criteria2]" approach (which I've used extensively, and is usually not a problem).

Here are the minimum scores (column G) to attain each rank (column F) Minimum values to achieve each rank

Version of xlookup that works as expected, only looking at a single value and array:

=xlookup([@score],ranks[score], ranks[rank],,-1)

Rank is correctly 1 for all three values

However, when I add in that contract field, suddenly Excel stops knowing the difference between the numeral 7 and 67.84 and 71.75, returning the rank attached to 67.84, which is clearly wrong.

=XLOOKUP([@Contract]&[@Score],Ranks[SERV_ABBR]&Ranks[SCORE],Ranks[RANK],,-1)

7 equals 70. That's probably fine, right?

This happens each time the Scores move from one ones place to the next, and then fixes itself and works perfectly when the scores are in the 10s and up, correctly returning 1st percentile rank until the score hits 67.84, as expected. So what am I doing wrong that I'm making Excel ignore the difference between 7 and 70?

I've rebuilt both tables repeatedly, and rewritten the formulas from scratch. I've checked that there are no extra spaces in the Contract/Serv_Abbr fields on each table (including working =(trim(clean()) functions into both the value and array fields. I've checked that the score columns in both tables are filled with numbers with 2 decimal places

I appreciate any help you can give. I usually use WAY more complicated versions of these formulas (nested if statements, dynamic comparisons and calculations on the returned data, etc.) so having such a simple variant kick my butt is both humbling and horrifying. Thanks!


Solution

  • AS7 is alphabetically greater than AS67.84 so you get the wrong answer.

    You could try formatting the numbers like this:

    =XLOOKUP([@Contract]&TEXT([@Score],"00.00"),Ranks[Serv_Abb]&TEXT(Ranks[Score],"00.00"),Ranks[Rank],,-1)
    

    to force the 7 to present as 07.00

    enter image description here

    Maybe I would prefer to filter on AS then do a lookup on the number to avoid the problem:

    =XLOOKUP([@Score],FILTER(Ranks[Score],Ranks[Serv_Abb]=[@Contract]),
    FILTER(Ranks[Rank],Ranks[Serv_Abb]=[@Contract]),,-1)