Extracts a string of characters from text, starting from the right. 

For example, if an automatically generated string ends with numbers that represent a date, you can use the RIGHT function to extract the date.

RIGHT(Text [, Number of characters])

ArgumentData typeDescription
Text

Text

Can be a line item, text constant, or general expression.

The text to extract characters from.
Number of characters (optional)

Number

Can be a line item, property, or expression.

The number of characters to extract from the text string.

If you omit this argument, the RIGHT function returns only the last, right, character from the text string.

If you use a negative number or zero for this argument, the RIGHT function returns a blank result.

If this argument is greater than the number of characters in the Text argument, the RIGHT function returns only the characters in the string.

The RIGHT function returns a text-formatted result.

RIGHT(Feedback ID, 10)

In this example, each piece of feedback Anaplan receives from another system has a unique code that identifies it. This ends with a 10 character string that corresponds to the date in the format dd-mm-yyyy.

This formula uses the Feedback ID line item for the Text argument and 10 for the Number of characters argument. As a result, this formula extracts the 10 characters that represent the date from the end of each feedback ID. This can then be used in other parts of the model or exported.

The RIGHT function cannot be used with list items. Convert list items to text-formatted with the NAME function if you need to use the RIGHT function with them.

In Polaris, the RIGHT function behaves as expected with all text values, including those that contain composite characters or characters from outside the Basic Multilingual Plane (BMP).

In the Classic Engine, the RIGHT function considers the length of:

  • Unicode characters from within the BMP to be 1
  • Unicode characters from outside the BMP to be 2
  • The length of composite characters (such as those with accents or diacritic marks) to be equal to the number of components

In this example, a Clothing list displays on columns, with four items, HatsShirtsShorts, and Trousers.

Three text-formatted line items display on rows, Red Product, Blue Product, and Yellow Product. These contain product names. There's also one list-formatted line item, Clothing List, which contains product types. These line items contain the values used for the Text argument.

The bottom four rows contain formulas that use the RIGHT function to extract characters from the right of the text strings.


HatsShirtsShortsTrousers
Red ProductRed HatsRed ShirtsRed ShortsRed Trousers
Blue ProductBlue HatsBlue ShirtsBlue ShortsBlue Trousers
Yellow ProductYellow HatsYellow ShirtsYellow ShortsYellow Trousers
Clothing ListHatsShirtsShortsTrousers
RIGHT(Red Product, 4)Hatsirtsortssers
RIGHT(Blue Product, 6)e HatsShirtsShortsousers
RIGHT(Yellow Product, 8)low Hatsw Shirtsw ShortsTrousers
RIGHT(NAME(Clothing List), 3)atsrtsrtsers

You can use the ITEM function to return the list-formatted column names. Then, you can use the NAME function to convert the names to be text-formatted, which is compatible with the RIGHT function.

In this example, the Fruit list displays on columns, and two line items display on rows. Both line items contain formulas.


ApplesPeachesBananasPearsCarrotsCucumbersLettuce
ITEM(Products)ApplesPeachesBananasPearsCarrotsCucumbersLettuce
RIGHT(NAME(ITEM(Products)), 5)pplesachesnanasPearsrrotsmbersttuce

RIGHT("Favorite Team", 4) 

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.