/    /  Amazon QuickSight – trim

Amazon QuickSight – trim

 

The ‘trim()’ function in Amazon QuickSight is used to remove whitespace characters (space, tab, and newline) from the beginning and end of a string expression. Here is an explanation of the trim() function:

 

Syntax

#Start#
trim(expression)
#End#

 

This function takes one argument:

 

  • expression: This is the string expression that is to be trimmed.

 

 

Suppose we have a dataset that contains information about employees’ names and their email addresses. We can use the trim() function in Amazon QuickSight to remove any leading or trailing spaces from the email addresses.

 

To remove the leading and trailing spaces from the email addresses, we can create a new calculated field in Amazon QuickSight with the following expression:

 

Example

#Start#
trim(email_address)
#End#

 

This expression will remove any leading or trailing spaces from the email addresses in our dataset.

 

For instance, if our email address data is as follows:

NameEmail Address
John Doejohn.doe@example.com
Jane Smithjane.smith@example.com
Bob Johnsonbob.johnson@example.com
Sally Leesally.lee@example.com
Jim Brownjim.brown@example.com

 

Then, the email address data with leading and trailing spaces removed will be:

NameEmail AddressEmail Address (trim)
John Doejohn.doe@example.comjohn.doe@example.com
Jane Smithjane.smith@example.comjane.smith@example.com
Bob Johnsonbob.johnson@example.combob.johnson@example.com
Sally Leesally.lee@example.comsally.lee@example.com
Jim Brownjim.brown@example.comjim.brown@example.com

 

In this example, we can see that the trim() function has removed any leading or trailing spaces from the email addresses, resulting in a cleaner and more consistent dataset.