MicroStrategy ONE

Length

The Length function returns the number of characters in an input string. For example, using the Length function on the string "MicroStrategy" would return a value of 13.

Syntax

Length(Argument)

Where:

  • Argument is a metric, fact, column, or string representing the text string(s).

Example

The Length function can be used in conjunction with other string functions to manipulate strings in various ways. For example, rather than abbreviating information to a specific number of characters, you can abbreviate each string to only display half of the available characters. The definition of an attribute form that displays only half of the characters available for the first names of customers is shown below:

LeftStr([CUST_FIRST_NAME], Int(Length([CUST_FIRST_NAME]) / 2))

For first names such as Alan, Fredrick, and Jennifer, the function shown above would display Al, Fred, and Jenn, respectively. This provides an abbreviated version of customers' first names while providing additional characters to possibly distinguish each abbreviated name.

In the function used in this example, the Int function is used to return only the integer part of the calculation Length([CUST_FIRST_NAME]) / 2. Depending on your database's support for functions, you could also use functions such as Round, Ceiling, and Floor. For information on these types of functions, see Mathematical functions.