
Extracts a number of characters from a string, starting from the rightmost character.
Syntax
RIGHT(Text [, Number of characters])
Argument | Data type | Description |
Text (required) | Text | The text to extract characters from. |
Number of characters (optional) | Number | The number of characters to extract from the text string. |
Returns
The RIGHT function returns a text-formatted result.
Arguments
The Text argument can refer to a text-formatted line item, text constant, or general expression.
The optional Number of characters argument can refer to a numeric line item, property, or expression. If you omit this argument, the default behavior returns only the rightmost character from the text string. If you use a negative number or zero for the Number of characters argument, the function returns a blank result. If the Number of characters argument is greater than the number of characters in the Text argument, the function returns only the characters in the string.
Constraints
The RIGHT function has this constraint:
- The RIGHT function cannot be used with list items. Convert list items to be text-formatted if you need to use the RIGHT function with them.
Excel equivalent
Examples
In this example, a Clothing list displays on columns, with four items, Hats, Shirts, Shorts, and Trousers.
Line items display on rows and are text-formatted. The exception to this is the Clothing List line item, which is list-formatted. The first three line items Red Product, Blue Product, and Yellow Product contain product names. These product line items are used for the Text arguments in the module’s formulas.
This table shows the formulas and their results for each of the list items Hats, Shirts, Shorts, and Trousers:
Formula | Result | Description |
RIGHT(Red Product, 4) |
Hats, irts, orts, sers | Returns the rightmost four characters of the text strings in the Red Product line item. |
RIGHT(Blue Product, 6) |
e Hats, Shirts, Shorts, ousers | Returns the rightmost six characters of the text strings in the Blue Product line item. |
RIGHT(Yellow Product, 8) |
low Hats, w Shirts, w Shorts, Trousers | Returns the rightmost eight characters of the text strings in the Yellow Product line item. |
RIGHT(NAME(Clothing List), 3) |
ats, rts, rts, ers | This formula extracts text from a list-formatted line item. The RIGHT function can only be used with text-formatted line items. This formula uses the NAME function to convert the list-formatted Clothing List line item to text-formatted. |
This example uses the RIGHT function with a text string typed directly into the formula. It uses 4 for the Number of characters argument. This means it returns Team, the last four characters of the text string.
RIGHT("Favorite Team",4)