Amazon QuickSight – Split
The ‘split’ function in Amazon QuickSight splits a string expression into an array of substrings based on a specified delimiter and returns the substring at the specified position in the array.
Syntax
#Start# split(expression, delimiter, position) #End#
This function takes three arguments:
- expression (required): the string expression to split.
- delimiter (required): the delimiter used to split the string.
- position (optional): the zero-based position of the substring to return. If this parameter is not provided, the entire array of substrings is returned.
Suppose you have a dataset containing a field with full names that you want to split into first and last names.
Assume the following dataset:
| Item | Properties |
| Apple | Red, Sweet, Crisp |
| Banana | Yellow, Sweet |
| Orange | Orange, Juicy |
| Pear | Green, Juicy |
| Peach | Fuzzy, Sweet |
| Mango | Yellow, Sweet |
| Kiwi | Brown, Tart |
To split the Properties field into separate fields for each property, you can use the split function:
- Select the dataset that you want to create calculated fields for.
- Click on the “Add field” button.
- Enter the following expressions:
Example
#Start# split({Properties}, ', ', 1) split({Properties}, ', ', 2) split({Properties}, ', ', 3) #End#
These expressions split the Properties field into three separate fields. The first expression returns the first property, the second expression returns the second property, and the third expression returns the third property.
- Click “Create field” to create the calculated fields.
After creating these calculated fields, you can use them for visualizations and analysis. In this example, the calculated fields would have the following values:
| Item | Properties | Property 1 | Property 2 | Property 3 |
| Apple | Red, Sweet, Crisp | Red | Sweet | Crisp |
| Banana | Yellow, Sweet | Yellow | Sweet | (null) |
| Orange | Orange, Juicy | Orange | Juicy | (null) |
| Pear | Green, Juicy | Green | Juicy | (null) |
| Peach | Fuzzy, Sweet | Fuzzy | Sweet | (null) |
| Mango | Yellow, Sweet | Yellow | Sweet | (null) |
| Kiwi | Brown, Tart | Brown | Tart | (null) |
Note that the “Property 1”, “Property 2”, and “Property 3” columns are calculated fields, and the values are not stored in the original dataset.