Amazon QuickSight – Ltrim
The ltrim() function in Amazon QuickSight is used to remove leading spaces from a string expression. This function returns a new string that has all the leading spaces removed.
Syntax
#Start# ltrim(expression) #End#
This function takes one argument:
- expression: This is the string expression from which the leading spaces or characters are to be removed.
Suppose we have a dataset that contains information about employees’ names and their departments. We can use the ltrim() function in Amazon QuickSight to remove any leading spaces from the department names.
To remove leading spaces from the department names, we can create a new calculated field in Amazon QuickSight with the following expression:
Example
#Start# ltrim(department) #End#
This expression will remove any leading spaces from the department column in our dataset.
For instance, if our department data is as follows:
| Name | Department |
| John Doe | HR |
| Jane Smith | Marketing |
| Bob Johnson | Operations |
| Sally Lee | Finance |
| Jim Brown | HR |
Then, the department data with leading spaces removed will be:
| Name | Department | Department (ltrim) |
| John Doe | HR | HR |
| Jane Smith | Marketing | Marketing |
| Bob Johnson | Operations | Operations |
| Sally Lee | Finance | Finance |
| Jim Brown | HR | HR |
In this example, we can see that the ltrim() function has removed the leading spaces from the department names, resulting in a cleaner and more consistent dataset.