1

convert numbers to ordinal numbers

I am using the rank() function in many klips, and I'd like to convert the number it returns to an ordinal number that I can use in a label. For example, if the ranking is 3, I'd like to display '3rd' instead of 3.

What is the easiest way to do this?

2 comments

  • Avatar
    Parker Selman Official comment

    Hi Trudy! 

    Thanks for the question - we can do this with a bit of formula logic to add the proper suffix to the ranks. 

    See this example below:


    This formula adds 'th' to all values between 10 and 19, and to any value that ends in a digit that isn't 1, 2, or 3, in which case, the proper suffix is added. 


    CONCAT(NUMBERFORMAT(&Data),
    IF(OR(&Data<10,&Data>19),
    SWITCH(right(&Data),1,"st",2,"nd",3,"rd","_default_","th"),
    "th"))

    I hope this helps! 

    Parker


  • 0
    Avatar
    Trudy Voorhees

    Parker - 

    Thanks for this! 

    --Trudy

     

Please sign in to leave a comment.