MicroStrategy ONE
SubStr (Substring Selection)
The SubStr
function returns a substring taken as a specified sequence of characters from the input string. SubStr
is useful for isolating a specific section of a string that contains relevant information.
Syntax
SubStr(
Argument
,
Position
,
Length
)
Where:
Argument
is a metric, fact, column, or string representing the text string(s).Position
is an integer indicating the starting position inside the string.Length
is an integer indicating the number of characters to be returned.
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
An LU_ITEM
table includes an ITEM_ID
column. This column stores a ten-digit number, which has been created to define various facts about the item. This includes two digits which identify the location in which the item is sold. These two digits always start at the fourth digit from the left side of the ten-digit item ID number. To retrieve these digits and determine the location of sale for an item, you can create an attribute form to return these two digits. The definition of such an attribute form is shown below:
SubStr(ITEM_ID, 4, 2)
The substring retrieved starts at the fourth digit and retrieves two characters. For an item ID of 2334560897
, this function returns 45
.