Skip to content

Instantly share code, notes, and snippets.

@ArrowstreamUK
Last active May 24, 2022 14:16
Show Gist options
  • Save ArrowstreamUK/c70528e0dfe18a79377f827f532fa327 to your computer and use it in GitHub Desktop.
Save ArrowstreamUK/c70528e0dfe18a79377f827f532fa327 to your computer and use it in GitHub Desktop.
This Excel lambda function provides the text suffix for positive ordinal integer values. It is useful when used with the rank function. So if you add a value of 32 then then output would be "nd". Similarly, 20 -> th, 21 -> st, 22 ->nd etc.
=LAMBDA(value,
LET(
mod_value,MOD(value,100),
IF(
(mod_value>=10)*(mod_value<=20),"th",
IF(
(MOD(mod_value,10)>=1)*(MOD(mod_value,10)<=3),
CHOOSE(MOD(mod_value,10),"st","nd","rd"),
"th"
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment