Descriptive Statistic & Basic Maths functions

ORDINAL

Reference

» Reference, Discussion, & Example Applications:

About

Returns the ordinal for a given number.

Inputs:

  • ar : array of numbers

Code

M.S. Excel
ORDINAL = LAMBDA(ar,
    IF(
        ar - INT(ar) <> 0,
        "#N/A",
        MAP(
            ar,
            LAMBDA(n,
                LET(
                    x, INT(RIGHT(n, 2)),
                    n &
                        IF(
                            OR(x = 11, x = 12, x = 13),
                            "th",
                            IFERROR(
                                CHOOSE(
                                    RIGHT(x),
                                    "st",
                                    "nd",
                                    "rd"
                                ),
                                "th"
                            )
                        )
                )
            )
        )
    )
);