/    /  Amazon QuickSight – Strlen

Amazon QuickSight – Strlen

 

The ‘strlen’ function in Amazon QuickSight returns the length of a specified string expression in characters.

 

Syntax

 

#Start#
strlen(expression)
#End#

 

This function takes one argument:

 

  • expression (required): the string expression to measure the length of.

 

Suppose you have a dataset containing a field with email addresses, and you want to create a calculated field that returns the length of each email address.

 

Assume the following dataset:

 

NameEmailAge
John Smithjohn.smith@example.com35
Jane Doejane.doe@example.com28
Bob Johnsonbob.johnson@example.com42

 

To create a calculated field that returns the length of each email address, you can use the strlen function:

 

  • Click on the “Add calculated field” button in the analysis pane.
  • Enter a name for the calculated field, such as “Email Length”.
  • Enter the following expression for the calculated field:

 

Example

 

#Start#
strlen({Email})
#End#

 

This expression returns the length of the email address in the current row.

 

  • Click “Create” to create the calculated field.

 

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

 

NameEmailAgeEmail Length
John Smithjohn.smith@example.com3519
Jane Doejane.doe@example.com2817
Bob Johnsonbob.johnson@example.com4220

 

The strlen function is useful for calculating the length of strings, which can be useful for various purposes such as data validation or formatting.