Ordinal Suffix

Version 3

    Description:

    Calculates the appropriate suffix for display of ordinal numbers (e.g. 1st, 2nd, 3rd, ...).

     

    This can improve readability when numbers are embedded in text such as headings, tooltips and annotations.

    Example Calculation:

    IF (RIGHT(STR([N]),1)="1") THEN
        IF (RIGHT(STR([N]),2)="11") THEN "th" ELSE "st" END
    ELSEIF (RIGHT(STR([N]),1)="2") THEN
        IF (RIGHT(STR([N]),2)="12") THEN "th" ELSE "nd" END
    ELSEIF (RIGHT(STR([N]),1)="3") THEN
        IF (RIGHT(STR([N]),2)="13") THEN "th" ELSE "rd" END
    ELSE
        "th"
    END
    

     

    [N] - An integer field.

    Comments:

    This calculation is based on a version contributed by Ty Alevizos in response to my much more convoluted version in the original Tableau Calculation Reference Library.