Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.

How do I get the last n characters of a string in table calculations?

0 0 2,327
Knowledge Drop

Last tested: Sep 19, 2017
 

You can take a substring from the end of a string by using the length function to calculate the starting point. Let n be the number of characters at the end you want to get:

substring(${field_name}, length(${field_name}) - (n-1), n)

If I want to get the last 4 digits of the license key for example:

substring(${license_key}, length(${license_key}) - 3, 4)

This works regardless of the length of the string.

Chat Tip: Many use cases for table calcs require multiple functions, combined in interesting ways. Think about how you can use the pieces you have to do what you want.

This content is subject to limited support.                

Version history
Last update:
‎06-14-2021 06:16 PM
Updated by: