1. Calculation functions
  2. All Functions
  3. Text functions
  4. RIGHT

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.

Syntax

RIGHT(Text [, Number of characters])

Arguments

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.

Syntax example

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.

Constraints

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.

Excel equivalent

Related Anaplan functions

Examples

Extract first word from line items

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 is 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

Use RIGHT with items from a list dimension

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

Example with text entered directly into formula

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.