Site icon i2tutorials

Amazon QuickSight – Substring

Amazon QuickSight – Substring

 

The ‘substring’ function in Amazon QuickSight is used to extract a portion of a string expression. It returns a new string that consists of a specified number of characters starting at a specified position in the original string.

 

Syntax

#Start#
substring(expression, start, length)
#End#

 

This function takes three arguments:

 

 

 

Suppose you have a dataset containing a field with product codes, and you want to create a calculated field that extracts the first three characters from each code.

 

Assume the following dataset:

 

Product NameProduct Code
Product AABC123
Product BDEF456
Product CGHI789

 

To create a calculated field that extracts the first three characters from each code, you can use the substring function:

 

Example

 

#Start#
substring({Product Code}, 0, 3)
#End#

 

This expression extracts the first three characters from the Product Code field in the current row.

 

 

After creating the calculated field, the dataset would include the following additional column:

 

Product NameProduct CodeProduct Code Prefix
Product AABC123ABC
Product BDEF456DEF
Product CGHI789GHI

 

The substring function is useful for extracting specific portions of a string, such as prefixes or suffixes, for various data analysis purposes.

 

Exit mobile version