MicroStrategy ONE

Position (Position of Substring)

The Position function returns the starting position of the first occurrence of a series of characters in the input string. For example, using the Position function to search for the string "Strategy" within the string "MicroStrategy" would return the value of 6.

To find the last occurrence of a series of characters in a string, see LastPosition (Last Position of Substring).

In addition to locating the position of a substring, Position also can be used to test whether the substring is present. If a given substring is not found, 0 will be returned.

Syntax

Position (Argument1, Argument2)

Where:

  • Argument1 is the substring to search for.
  • Argument2 is the string in which to search for Argument1.

For information on the syntax used in your specific database, see MicroStrategy and Database Support for Functions and see the section that corresponds to your database.

Example

The Position function can be used in conjunction with other functions to perform various manipulations on strings. For an example of how this function works, consider an LU_CUSTOMER table that includes an ADDRESS column. You use the Position function to find the word Street in the addresses as defined below.

Position("Street", [ADDRESS])

For an address of 10 Main Street, the function listed above returns the value of 9. For addresses that do not include the word Street, a value of 0 would be returned.