/    /  Amazon QuickSight  – Locate

Amazon QuickSight  – Locate

 

The Amazon QuickSight LOCATE() function is used to search for a substring within a string and return the position of the first occurrence of the substring.

Syntax

#Start#
LOCATE(substring, string [, start])
#End#

 

This function takes three arguments

 

  • substring: The substring that you want to search for in the string parameter.
  • string: The string in which you want to search for the substring.
  • start (optional): The starting position from where the search should begin. If not specified, the search starts from the beginning of the string.

 

 

The function returns an integer value that represents the position of the first occurrence of the substring within the string. If the substring is not found, the function returns zero.

 

Here’s an example of how to use the LOCATE() function in Amazon QuickSight:

Example

#Start#
LOCATE('apple', 'I like to eat apples and bananas.')
#End#

 

In this example, the function will search for the substring “apple” within the string “I like to eat apples and bananas.” and return the position of the first occurrence of the substring, which is 13.

You can also specify a starting position for the search, like this:

Example

#Start#
LOCATE('apple', 'I like to eat apples and bananas.', 15)
#End#

 

In this example, the search for the substring “apple” will start at position 15 of the string “I like to eat apples and bananas.”, and the function will return 0, because the substring is not found after position 15.