Site icon i2tutorials

Amazon QuickSight – Replace

Amazon QuickSight – Replace

 

The replace function in Amazon QuickSight replaces all occurrences of a substring within a string expression with a specified replacement string.

 

Syntax

#Start#
replace(expression, substring, replacement)
#End#

 

This function takes three arguments:

 

 

 

Suppose you have a dataset containing a field with a string expression that contains a specific substring that you want to replace with another string.

 

Assume the following dataset:

 

ItemDescription
AppleFresh apples
BananaRipe bananas
OrangeSweet oranges
PearJuicy pears

 

To replace the word “apples” with “fruit” in the Description field, you can use the replace function:

 

 

Example

 

#Start#
replace({Description}, "apples", "fruit")
#End#

 

This expression replaces all occurrences of the substring “apples” in the Description field with the string “fruit.” The resulting calculated field will contain the modified string expressions.

 

 

After creating this calculated field, you can use the modified string expressions for visualizations and analysis. In this example, the calculated field would have the following values:

 

ItemDescriptionModified Description
AppleFresh applesFresh fruit
BananaRipe bananasRipe bananas
OrangeSweet orangesSweet oranges
PearJuicy pearsJuicy pears

 

Note that the “Modified Description” column is a calculated field, and the values are not stored in the original dataset. Also note that the replace function is case-sensitive, so it will only replace the substring with the exact same case.

 

Exit mobile version