Search code examples
excelexcel-formularankingexcel-365

Rank numbers including NA()s in Excel 365


Let's say I have a list of numbers including a few NA()s.

In the previous versions of Excel I have used the following formula and it worked (not very elegant mind you):

=IFERROR(MATCH(F8, AGGREGATE(15, 6, F$2:F$10, ROW(INDIRECT("1:"&COUNT(F$2:F$10)))), 0), "")

I have updated it slightly in Excel 365 to:

=IFERROR(MATCH(F2, AGGREGATE(15, 6, F$2:F$10, SEQUENCE(COUNT(F$2:F$10))), 0), "")

And next completely re-wrote it as a LET formula (LET makes everything better ®):

=LET(
    values, F$2:F$10,
    ranks, SORT(FILTER(values, ISNUMBER(values)), 1, 1),
    IFERROR(MATCH(F2, ranks, 0), "")
)

The last version can be compacted to:

=IFERROR(MATCH(F2, SORT(FILTER(F$2:F$10, ISNUMBER(F$2:F$10))), 0), "")

All formulas work as they should, but I can't stop thinking I'm missing something to make the formula even more compact and shorter. Any ideas?

enter image description here


Solution

  • I think XMATCH() with SORT() may be simplest one. Try-

    =IFERROR(XMATCH(F2,SORT($F$2:$F$10)),"")
    

    enter image description here