How To Add An Ordinal Suffix (1st, 2nd, 3rd) To A Number In Power Apps



Summary

This formula will convert a number to a text value with an ordinal suffix (1st, 2nd, 3rd… 100th)



Example


Inputs

Number22


Code

Set(
    varSolution,
    With(
        {
            varNumber: Text(TextInput_1.Text),
            varSuffix: Table(
                {
                    val: "th",
                    key: "11"
                },
                {
                    val: "th",
                    key: "12"
                },
                {
                    val: "th",
                    key: "13"
                },
                {
                    val: "st",
                    key: "1"
                },
                {
                    val: "nd",
                    key: "2"
                },
                {
                    val: "rd",
                    key: "3"
                }
            )
        },
        Concatenate(
            Text(varNumber),
            Coalesce(
                LookUp(varSuffix, key=Right(varNumber,2), val),
                LookUp(varSuffix, key=Right(varNumber,1), val),
                "th"
            )
        )
    )
)


Result

22nd