/    /  Amazon QuickSight – startsWith

Amazon QuickSight – startsWith

 

The ‘startsWith’ function in Amazon QuickSight is used to determine whether a string expression starts with a specified substring. It returns a Boolean value of true or false depending on whether the substring is found at the beginning of the expression.

 

Syntax

 

#Start#
startsWith(expression, substring, string-comparison-mode)
#End#

 

This function takes three arguments:

 

  • expression (required): The string to search for the substring. This can be a field, column, or expression that returns a string value.
  • substring (required): The substring to search for at the beginning of the expression. This can be a string literal or an expression that returns a string value.
  • string-comparison-mode (optional): The string comparison mode to use. This parameter is optional and can be used to specify how the comparison should be performed. Possible values are: case-sensitive (default), case-insensitive, and accent-sensitive.

 

 

Suppose you have a dataset containing a field with product names, and you want to filter the dataset to show only products that start with the word “Amazon”.

 

Assume the following dataset:

 

Product NamePrice
Amazon Echo Dot$49
Google Nest Mini$39
Amazon Fire TV Stick$39
Apple HomePod Mini$99
Amazon Kindle$89
Amazon Basics Mouse$10

 

To create a filter that only shows products that start with the word “Amazon”, you can use the startsWith function:

 

  • Create a filter by clicking on the “Add filter” button in the analysis pane.
  • Select the “Product Name” field to filter by.
  • Enter the following expression for the filter:

Example

 

#Start#
startsWith({Product Name}, "Amazon")
#End#

 

This expression returns true for any product name that starts with the word “Amazon” and false for any product name that does not.

 

  • Click “Apply” to apply the filter.

 

After applying the filter, the dataset would show only the following rows:

 

Product NamePrice
Amazon Echo Dot$49
Amazon Fire TV Stick$39
Amazon Kindle$89
Amazon Basics Mouse$10

 

Note that the filter is case-sensitive by default, so it only matches product names that start with the exact sequence of characters “Amazon”. If you want to do a case-insensitive match, you can set the string-comparison-mode parameter to “ignore case”, like this:

 

Example

 

#Start#
startsWith({Product Name}, "amazon", "ignore case")
#End#