Amazon QuickSight – Right
The right function in Amazon QuickSight returns a specified number of characters from the right side of a string expression.
Syntax
#Start# right(expression, limit) #End#
This function takes two arguments:
- expression (required): the string expression that contains the characters to extract.
- limit (required): the number of characters to return from the right side of the string expression.
Suppose you have a dataset containing a field with a string expression that you want to extract the last few characters from.
Assume the following dataset:
| Item | Description |
| Apple | Fresh apples |
| Banana | Ripe bananas |
| Orange | Sweet oranges |
| Pear | Juicy pears |
To extract the last 3 characters of the Description field, you can use the right function:
- Select the dataset that you want to create a calculated field for.
- Click on the “Add field” button.
- Enter the following expression:
Example
#Start# right({Description}, 3) #End#
This expression extracts the last 3 characters from the Description field. The resulting calculated field will contain the extracted characters.
- Click “Create field” to create the calculated field.
After creating this calculated field, you can use the extracted characters for visualizations and analysis. In this example, the calculated field would have the following values:
| Item | Description | Last 3 Characters |
| Apple | Fresh apples | les |
| Banana | Ripe bananas | nas |
| Orange | Sweet oranges | ges |
| Pear | Juicy pears | ars |
Note that the “Last 3 Characters” column is a calculated field, and the values are not stored in the original dataset.