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

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: