MicroStrategy ONE

Length (Length of String)

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. Length is often used to manipulate strings with the help of other string functions.

Syntax

Length(Argument)

Where:

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

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

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, Frederick, 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.