In ArcGIS Arcade, Right(value, numChars) returns a text value containing the specified number of characters from the end of a string. For example, Right("Arcade", 3) returns "ade"; use it when an expression needs to extract a suffix, code ending, or other rightmost text.
What the Right function does
Arcade is Esri’s expression language for working with geographic data and configuring behavior in ArcGIS products. Its Right() function is a text operation: it reads characters from the right-hand end of a value and returns them as text. It does not change the source field, move a map feature, or mean “right” as a compass direction.
The function is useful when a field stores information in a predictable text pattern. A road identifier might end in a route class, an asset code might end in a four-digit sequence, or a parcel label might end in a short district code. If the portion you need is consistently at the end, Right() can isolate it without requiring a longer expression that searches through the whole value.
The number of characters is counted from the end of the string. Thus, taking three characters from "Arcade" produces "ade", while taking two produces "de". The result is a substring, not a number: if the extracted characters look numeric, they are still text unless you explicitly convert them.
Syntax and arguments
The general syntax is Right(value, numChars). The first argument is the text to examine, and the second is how many characters to return from its end. Use a nonnegative whole-number count appropriate for the text you are processing.
value: the string, field value, or expression whose ending characters you want.numChars: the number of characters to take from the right side.
For example, Right("Maple Avenue", 7) returns "Avenue". Spaces count as characters, so the seven-character result begins with the space before the word. This matters when a field contains names, formatted labels, or codes separated by spaces. If the result should not include a separator, adjust the count or clean the source string before extracting the suffix.
Use the Arcade function name as shown, including its capitalization, and place the arguments in parentheses separated by a comma. As with other expression languages, a function call must be part of a valid Arcade expression for the profile in which it runs.
Basic examples
These examples show the operation on literal strings. The comments describe the returned value:
Right("Arcade", 3)returns"ade".Right("Route 66", 2)returns"66".Right("AB-1048", 4)returns"1048".
The function does not know what a code means. In the last example, it simply takes the final four characters. If a value changes format—for example, some identifiers end in three digits and others in five—a fixed count may extract inconsistent information. Before relying on a fixed-width suffix, check that the source data follows the same pattern across the records you will use.
A count equal to the string’s length returns the whole string. A count larger than the available number of characters does not create missing characters; in ordinary use, it gives you the available text. When the count is zero, the intended result is an empty string. Test edge cases with representative values in the Arcade profile and app where the expression will run, particularly if the source data may be blank or irregular.
Using Right with feature attributes
In a feature expression, the input often comes from an attribute accessed through $feature. Suppose a layer has a text field named AssetCode containing values such as "PUMP-4827". The expression Right($feature.AssetCode, 4) extracts "4827" for that feature. In a popup or label expression, the result can be used to show just the final code segment instead of the full identifier.
For a field named RouteName with a value such as "County Road 18", Right($feature.RouteName, 2) returns "18". That shortcut is appropriate only if the route number always occupies the final two characters. It would not correctly handle a one-digit or three-digit route number, or a name with extra text after the number. Data structure, not the function, determines whether a fixed character count is reliable.
Arcade expressions run in profiles, and a profile defines which variables and operations are available. A popup expression, label expression, visualization expression, and calculation expression can have different purposes and output expectations. The basic string function is broadly useful, but confirm that the expression’s profile exposes the field you reference and accepts the kind of result you return. In ArcGIS Online or ArcGIS Pro, use the relevant Arcade editor and its profile documentation when adapting an expression to a particular workflow.
Combining Right with other text operations
Right() becomes more powerful when paired with other string functions. For example, a value may have unwanted leading or trailing spaces. Trimming the input before taking its suffix can prevent a trailing space from being counted as one of the requested characters. Arcade provides text functions such as Trim() for that kind of cleanup; check the function reference for the exact behavior you need.
You can also use Right() as part of a larger expression. For example, a popup might combine a fixed label with an extracted ending, or a conditional expression might show a suffix only for a particular category. Keep the extraction separate and readable while developing: first confirm which substring the function returns, then add formatting or conditional logic. This makes it easier to tell whether a problem comes from the character count, the field value, or the surrounding expression.
Be careful when converting data types. A numeric attribute is not the same as a text code. If an identifier is stored as a number, leading zeros may already have been discarded—for instance, a stored number cannot preserve whether its original display was 4827 or 004827. Converting a number to text cannot restore information that is no longer present. For codes where every digit matters, storing the identifier as text is usually the sounder data design.
Choosing a character count
A fixed count works best for fixed-width formats. If every asset identifier ends with exactly four characters that carry the same meaning, taking four is straightforward. If the suffix length varies, use a delimiter or a more suitable parsing method rather than assuming that the last four characters always form the desired field.
Before publishing an expression, consider these checks:
- Inspect short, long, and typical values in the source field.
- Confirm whether spaces, hyphens, or punctuation are included in the requested character count.
- Check that the suffix has the same meaning and width across categories.
- Decide how blank, null, or malformed values should appear in the output.
- Test the expression in the actual app and Arcade profile where people will see or use it.
These checks can prevent a subtle display error from looking like valid data. An expression may run successfully yet return the wrong segment because a few records do not follow the assumed pattern.
Common mistakes and troubleshooting
A frequent mistake is counting characters from the left rather than the right. Right("AB-1048", 4) returns the ending "1048", not the first four characters. If the output is unexpected, write out the exact source value and mark the final characters being counted; this often reveals an unnoticed separator or space.
Another mistake is treating the result as a number. A suffix such as "0042" is text, which is often exactly what an identifier needs. Turning it into a numeric value can remove leading zeros or make later text concatenation behave differently. Keep identifiers as text unless a calculation genuinely requires numeric arithmetic.
If an expression behaves differently across features, compare the stored attribute values, not just how they are displayed in a table or popup. Formatting can make values look uniform while the underlying data contains spaces, nulls, or inconsistent punctuation. Also verify the field name and the expression’s profile. A valid function call cannot compensate for referencing an unavailable or differently named field.
How Right differs from similar functions
Choose a text function based on where the desired part occurs. Right() takes a fixed number of characters from the end; Left() takes characters from the beginning. A middle section calls for a function designed to extract text from a specified position, while a value separated by a reliable delimiter may be better handled by splitting or finding that delimiter.
This distinction is useful for structured values. For "ZONE-NE-07", taking two characters from the right returns "07". But if you need "NE", a fixed rightmost count would also include part of the ending or require assumptions about the length of the final segment. Parsing around the hyphens better expresses the structure and is usually easier to maintain if segment lengths change.
Do not confuse Arcade’s Right() with the right side of a map, screen, or direction indicator. This function operates only on text. For map direction, geometry, or interface layout, use the appropriate mapping or application tools instead.
Frequently Asked Questions
What does Right() return in Arcade?
It returns the requested number of characters from the end of its input. For example, Right("Arcade", 3) returns "ade".
Is Right() case-sensitive?
The characters returned keep their original capitalization; Right() does not convert text to upper- or lowercase. If you need normalized case, combine the extraction with an appropriate case-conversion function.
Can Right() extract digits from an ID?
Yes. If the ID is text and ends in a predictable number of digits, the function can return those characters. The result remains text, which helps preserve leading zeros.
Does Right() work on a number field?
It is intended for text extraction. If the source is numeric, convert it to text deliberately and consider whether the stored number has already lost significant leading zeros. For identifiers, text fields are generally safer.
Why is Right() returning an unexpected character?
Check the exact stored value and count every character, including spaces and punctuation. Also check for inconsistent suffix lengths, blank values, and whether the expression references the field you intended.
Can I use Right() in any ArcGIS expression?
Arcade supports different expression profiles for different tasks. The function may be suitable for many text expressions, but check the profile and app documentation to confirm the available inputs and expected output.
Related
- Split a Column in Snowflake: SQL Methods and Examples
- Java String matches(): How Regex Matching Works
- MS Access: How to Split a Database for Multiple Users
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Date Countdown Formula: Calculate Days Left in ExcelIf the target date is in cell B2, enter =B2-TODAY() in another cell to show the number of…
- Excel Payment Tracker: Setup, Formulas, and Practical TipsAn Excel payment tracker is a worksheet for recording what is owed, what has been paid, when payments…
- VLOOKUP to Compare Two Columns on Different SheetsYes. In Excel for Microsoft 365, use an exact-match VLOOKUP to check whether each value in one sheet’s…
- Excel INDEX and AVERAGE: How to Combine ThemExcel has no single function called INDEX AVERAGE; instead, combine INDEX with AVERAGE so Excel averages the value…
- Excell Battery SDS: How to Find the Right SheetAn Excell battery does not have one universal SDS: the correct safety data sheet depends on the battery’s…
- Excel Filter Dates by Day of Week: Methods That WorkExcel’s date filter menu does not include a direct day-of-week option, but you can filter weekdays by adding…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.