/    /  Amazon QuickSight – Split

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:

ItemProperties
AppleRed, Sweet, Crisp
BananaYellow, Sweet
OrangeOrange, Juicy
PearGreen, Juicy
PeachFuzzy, Sweet
MangoYellow, Sweet
KiwiBrown, 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:

 

ItemPropertiesProperty 1Property 2Property 3
AppleRed, Sweet, CrispRedSweetCrisp
BananaYellow, SweetYellowSweet(null)
OrangeOrange, JuicyOrangeJuicy(null)
PearGreen, JuicyGreenJuicy(null)
PeachFuzzy, SweetFuzzySweet(null)
MangoYellow, SweetYellowSweet(null)
KiwiBrown, TartBrownTart(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.