Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MicroStrategy Functions Reference

Download as pdf or txt
Download as pdf or txt
You are on page 1of 849

Fu n ct i on s

Re f e r e n ce

Version 2021
M i cr o St r at egy 2021

Oct o b er 2023
Copyright © 2023 by MicroStrategy Incorporated. All rights reserved.
Trademark Information
The following are either trademarks or registered trademarks of MicroStrategy Incorporated or its affiliates in the United States and certain other
countries:
Dossier, Enterprise Semantic Graph, Expert.Now, Hyper.Now, HyperIntelligence, HyperMobile, HyperVision, HyperWeb, Intelligent Enterprise,
MicroStrategy, MicroStrategy 2019, MicroStrategy 2020, MicroStrategy 2021, MicroStrategy Analyst Pass, MicroStrategy Architect, MicroStrategy
Architect Pass, MicroStrategy Badge, MicroStrategy Cloud, MicroStrategy Cloud Intelligence, MicroStrategy Command Manager, MicroStrategy
Communicator, MicroStrategy Consulting, MicroStrategy Desktop, MicroStrategy Developer, MicroStrategy Distribution Services, MicroStrategy
Education, MicroStrategy Embedded Intelligence, MicroStrategy Enterprise Manager, MicroStrategy Federated Analytics, MicroStrategy Geospatial
Services, MicroStrategy Identity, MicroStrategy Identity Manager, MicroStrategy Identity Server, MicroStrategy Insights, MicroStrategy Integrity
Manager, MicroStrategy Intelligence Server, MicroStrategy Library, MicroStrategy Mobile, MicroStrategy Narrowcast Server, MicroStrategy ONE,
MicroStrategy Object Manager, MicroStrategy Office, MicroStrategy OLAP Services, MicroStrategy Parallel Relational In-Memory Engine (MicroStrategy
PRIME), MicroStrategy R Integration, MicroStrategy Report Services, MicroStrategy SDK, MicroStrategy System Manager, MicroStrategy Transaction
Services, MicroStrategy Usher, MicroStrategy Web, MicroStrategy Workstation, MicroStrategy World, Usher, and Zero-Click Intelligence.
The following design marks are either trademarks or registered trademarks of MicroStrategy Incorporated or its affiliates in the United States and certain
other countries:

Other product and company names mentioned herein may be the trademarks of their respective owners.
Specifications subject to change without notice. MicroStrategy is not responsible for errors or omissions. MicroStrategy makes no warranties or
commitments concerning the availability of future products or versions that may be planned or under development.
CON TEN TS
1. Understanding Functions in MicroStrategy 5

The Basics of MicroStrategy Objects, Object Definitions, and Functions 6


Function Syntax and Formula Components 9
Using Functions in Expressions 35
How MicroStrategy Processes Functions 60

Additional Examples of Functions in Expressions 83

2. Standard Functions 114

Basic Functions 116


Date and Time Functions 149
Internal Functions 169
NULL/Zero Functions 188
OLAP Functions 191
Pattern Functions 265
Rank and NTile Functions 268
String Functions 293

3. Operators 319

Arithmetic Operators 320


Comparison Operators 323
Comparison for Rank Operators 334
Logical Operators 338

4. Plug-In Package Functions 342

Data Mining Functions 343


Financial Functions 347
Mathematical Functions 415
Statistical Functions 439

A. MicroStrategy and Database Support for Functions 494

Analytical Engine Support for Functions 495


Databases That a Function Can Be Evaluated On 500
Fu n ct io n s Refer en ce

U N D ERSTAN D IN G
FUN CTION S IN
M ICRO STRATEGY

Copyright © 2023 All Rights Reserved 5


Fu n ct io n s Refer en ce

This chapter provides the following information:

l The Basics of MicroStrategy Objects, Object Definitions, and Functions,


page 6

l Function Syntax and Formula Components, page 9

l Using Functions in Expressions, page 35

l Adding Functions to Expressions with the Insert Function Wizard, page 57

l How MicroStrategy Processes Functions, page 60

l Additional Examples of Functions in Expressions, page 83

The Basics of MicroStrategy Objects, Object


Definitions, and Functions
To understand functions and their role in MicroStrategy, it is important to
grasp the basic concepts underlying objects and expressions.

An object is a basic building block in MicroStrategy. There are three types of


objects: schema objects, application objects, and configuration objects.
Schema objects include facts, hierarchies, and custom groups; application
objects include reports, documents, and metrics; and configuration objects
include project sources, database instances, and users. (This list of objects
is not exhaustive.)

MicroStrategy objects are created, maintained and deleted by you. Your


Architect, for instance, will create attributes by mapping conceptual data
from your data warehouse to names like Month, Customer Name, or Product
Category that will appear on your reports. Your Designer will create metrics
that access and manipulate numeric data from your data warehouse.

Many objects require you to specify an expression when creating or


modifying them. An expression is any combination of characters that can be
used as a result. Examples include the following:

Copyright © 2023 All Rights Reserved 6


Fu n ct io n s Refer en ce

l Month + 5

l Sum(Revenue)

l New York AND Los Angeles

In the first example, each Month element in your data warehouse is assigned
a numeric ID between 1 and 12, where January is 1, February is 2, and so
on. You want to generate a report with a five-month forecast. One approach
would begin with creating a new attribute called 5 Months Ahead, using the
expression Month + 5 in its attribute definition.

Expressions can be used in many places. Metrics in particular often require


complicated expressions. In the second example above, the expression Sum
(Revenue) is used to define a relatively simple metric. "Sum" tells
MicroStrategy to read individual Revenue entries from the data warehouse
and add them together to produce one single number that will be displayed
as Revenue on your report. This metric is a MicroStrategy object that you
can create.

The last example above shows a logical expression, which might be used in
a filter. A filter comprised of the expression New York AND Los Angeles
would let a user answer questions such as "Which business travelers flew
out of New York and out of Los Angeles in 2006?"

Expressions often form the basis of objects, which are the basic building
blocks of all MicroStrategy content and functionality. Objects that rely on
these expressions are often edited by changing the object expressions.

In this book, the terms "object expression" and "object definition" are
interchangeable unless otherwise noted.

To create an expression that accomplishes your goal, you will almost always
utilize a MicroStrategy function. Functions in MicroStrategy are powerful
tools used to define MicroStrategy objects (when they are integrated into
object definitions) and initiate complex user-selected calculations. The
example Sum(Profit) in a metric definition uses the Sum function to add

Copyright © 2023 All Rights Reserved 7


Fu n ct io n s Refer en ce

various Profit entries in a data warehouse to arrive at one final number to


display on a report.

Wherever you use an expression, you can use a function. From creating
basic objects to building complex reports and analyzing data, you can create
custom expressions using a large library of functions that come with and are
supported by MicroStrategy. Although functions are most commonly used in
metric expressions, they are also used to define attribute forms,
consolidation elements, custom groups, filters, facts, subtotals, and
transformations, all of which are MicroStrategy objects.

Functions Commonly Used to Create Specific Objects


The following table lists the function types described above, several
functions belonging to each type, and the MicroStrategy objects that can be
created using those functions.

Function MicroStrategy Objects That Can Use


Function Examples
Type These Functions

• Attribute form
• Arithmetic
operators • Consolidation
( –, +, /, *)
• Custom group
• Abs
Single-value • Fact
• Round
• Metric
• Ln
• Subtotal
• Cos
• Transformation

• Avg
• Metric
Group-value • Count
• Subtotal
• Sum

• Rank
OLAP Metric
• MovingMin

Copyright © 2023 All Rights Reserved 8


Fu n ct io n s Refer en ce

Function MicroStrategy Objects That Can Use


Function Examples
Type These Functions

• NTile

• And
Logical Filter
• Or

• Between
Comparison Filter
• ApplyComparison

• Attribute form

• ApplySimple • Consolidation

• ApplyAgg • Custom group

Apply • ApplyOLAP • Fact

• ApplyLogic • Metric

• ApplyComparison • Transformation

• Filter

Function Syntax and Formula Components


You can use functions in any situations where you build an expression.
Although an expression can have unique characteristics, there is a basic
syntax for applying functions in expressions. The use of each function is
described in detail in the rest of this book. This section covers the basics of
functions and their key components.

Each function is designated by a function name. Functions operate on an


argument that can be a fact, attribute, metric, or constant, and the function's
behavior is often further specified using one or more parameters. Function
parameters are used to fine-tune the behavior of functions. Arguments
provide the inputs to functions.

Copyright © 2023 All Rights Reserved 9


Fu n ct io n s Refer en ce

In this guide, MicroStrategy functions are grouped into function types. This
section provides information on function types, as well as their parameters
and arguments.

This guide does not include information on Data Mining functions. This
information can be found in the Data Mining Services chapter of the
Advanced Reporting Help.

Function Types
MicroStrategy functions are classified into the following types:

l Single-value functions (also known as Non-grouping or Scalar


functions): These functions operate on each individual component of an
input variable or argument, resulting in an output element for each
component. Examples of this category are simple mathematical operators
(+, -, *, /), Abs, Accrint, Ddb, Cos, Ln, Round, Truncate, ApplySimple, and
so on. For details, see Single-Value Functions, page 11.

l Group-value functions (also known as Grouping or Aggregate functions):


These functions take one or more lists of values as input and generate a
single output value for each list. Examples of this category are Avg,
AvgDev, Correlation, Count, HomoscedasticTTest, Intercept, Slope,
StDev, Sum, ApplyAgg, and so on. For details, see Group-Value
Functions, page 13.

l OLAP functions (also known as Relative functions): These functions take


multiple elements from a list and return a new list of elements. Each
element is related to and dependent on one or more other elements in the
list, and the relative positions of elements within the list determines how
computation is performed. Examples include Rank, RunningSum,

Copyright © 2023 All Rights Reserved 10


Fu n ct io n s Refer en ce

MovingAvg, NTile, ApplyOLAP, and so on. For details, see OLAP


(Relative) Functions, page 14.

l Comparison operators: These operators compare single values or lists of


values, or compare a list to a threshold value. Examples of this category
are Between, Like, Greater than(>), Less than (<), ApplyComparison, and
so on. For details, see Comparison Operators, page 16.

l Logical operators: These operators provide basic comparisons and


return TRUE or FALSE values based on the evaluation of the formula. This
type of operator includes And, Or, and Not. For details, see Logical
Operators, page 17.

l Apply functions: These functions provide access to functions and


syntactic constructs that are not standard in MicroStrategy but are offered
by various relational database management system (RDBMS) platforms.
Each of the functions in this category substitutes for one of the function
types mentioned above and can be used wherever that type is used. For
example, ApplySimple can be used wherever a single-value function is
used. For details, see Apply (Pass-Through) Functions, page 17.

In this guide, lists of attributes, metrics, values, parameters, etc. within a


function are separated by commas. Your separator may vary depending on
your number and date format locale. For example, the separator is a comma
(,) in English and a semicolon (;) in German.

Single-Value Functions
A single-value function operates on each individual component of one or
more arguments, resulting in an output component for each set of input
components. Subtraction, addition, division, and multiplication operators (–,
+, /, *) are common examples of single-value functions. Other examples
include Abs, Cos, Ln, Round, Sin, Trunc, ApplySimple, and so on.

Single-value functions can be used to create facts, metrics, attribute forms,


consolidation elements, and transformations.

Copyright © 2023 All Rights Reserved 11


Fu n ct io n s Refer en ce

For example, using a single-value function that operates on four arguments,


where each argument is composed of a five-component list, returns five
components. In other words, the number of output components is equal to
the number of input components in each argument. A simple example using
numbers follows:

Using the single-value "+" (addition) function, A+B=C

Where

l A=1 (an argument containing one component whose value is 1)

l B=2 (an argument containing a single component whose value is 2)

l C=3 (the returned value, containing a single output component, whose


value is 3)

In the example above, A, B, and C each contain one component. More


generally, given variables D and E used as arguments in the addition
function, where D and E each contain a five-component list, D+E results in
a five-component list. Single-value functions need not take a single value as
an argument or even a single argument. Rather, the basic requirement for a
function to be categorized as single-value is that the number of output
components equals the number of input components of the arguments.

The following two examples illustrate the use of single-value functions in the
creation of a transformed fact and a compound metric. Transforming a fact
and creating a compound metric are similar in that both use a single-value
function to turn one or more lists of values into another list of values. They
differ in that, for a transformation, the single-value function must be applied
before a group-value function, while in a compound metric the single-value
function is applied after the group-value function.

Exam ple 1: Transform ed Fact


Avg(Abs([Account Transactions]))

Copyright © 2023 All Rights Reserved 12


Fu n ct io n s Refer en ce

Suppose Account Transactions is a list of the following values: -300.5, -7.7,


900, -80, and 2.2. The single-value function, Absolute, is applied to the list.
The result set is the absolute value of each element in the list: 300.5, 7.7,
900, 80, 2.2. It is important to note that the single-value function returns five
elements of output for five elements of input. Once the single-value function
has been applied, the group-value function, Avg, is applied to produce an
average of those values, 258.08. For more information on the Abs and Avg
functions, see Abs (Absolute Value), page 416 and Avg (Average), page
117.

Exam ple 2: Com pound Metric


Avg(Revenue){Quarter} - Avg(Cost){Quarter}

In this example, the group-value function Avg is applied to both the Revenue
and Cost facts in your data warehouse. First, MicroStrategy uses the list of
values for the two input variables Revenue and Cost to generate, using the
Avg function twice, two new variables each containing a single value. The
two resulting variables are stored as intermediate results. Next, the single-
value function "-" (subtraction) is applied by MicroStrategy to subtract one
intermediate result from the other, resulting in a single value for the metric.
For more information on the Abs and Avg functions, see Abs (Absolute
Value), page 416 and Avg (Average), page 117.

In both of the previous examples, both single-value and group-value


functions were used. The next section addresses group-value functions in
more detail.

Group-Value Functions
A group-value function takes one or more lists of values as input and returns
a single output value for each list. The existence of a GROUP BY clause in a
SQL statement indicates that you are using a group-value function.

The most common group-value functions include Avg, Count, Max, Median,
Min, Stdev, Sum, Var, ApplyAgg, and so on. First, Last, IRR, and NPV

Copyright © 2023 All Rights Reserved 13


Fu n ct io n s Refer en ce

functions also belong to this category, but they have an additional sort by
feature (for more information, see Common Parameters, page 27). Sort by
specifies the order that the values returned by an expression will appear on
a report. (For more information on the SortBy parameter, see BreakBy and
SortBy Parameters, page 27.)

Group-value functions can be used to create simple metrics, nested metrics,


and compound metrics, as well as in the calculation of subtotals. The
following examples illustrate their use.

Exam ple 1: Average


Avg([Employee Age])

In this example, the group-value function Avg operates on the argument


Employee Age, which is a list of the following elements: 27, 35, 32, 47, 43,
40, 30. The function reduces the seven elements of the input value to a
single output value of 36. For more information on the Avg function, see Avg
(Average), page 117.

Exam ple 2: Median


Median([Employee Age])

The only difference between Example 2 and Example 1 above is the fact that
the group-value function, Median, is used, instead of Avg. Again, the
function reduces the seven elements of the input value to a single output
value of 35. For more information, see Median, page 134.

OLAP (Relative) Functions


Online Analytical Processing (OLAP) functions are also referred to as
Relative functions because each element in a list of values is related to and
dependent on one or more other elements in the list, and the positions of the
elements within the list determine how computation is performed.

Copyright © 2023 All Rights Reserved 14


Fu n ct io n s Refer en ce

An OLAP function takes multiple elements from a list and returns a new list
of elements. Unlike group-value functions, though, the number of elements
in the input list and the number of elements in the output list remains the
same. Unlike single-value functions, the computation depends upon the
conditions set by the BreakBy parameter that defines when the calculation
restarts and the SortBy parameter that defines how the list of values is
sorted (see Common Parameters, page 27).

OLAP functions include Rank, all the functions with Moving as the prefix of
the name (for example, MovingDifference, MovingMin, MovingStdev,
and so on), all the functions with Running as the prefix (for example,
RunningAvg, RunningCount, RunningSum, and so on), and all the NTile
functions (such as NTile, NTileSize, NTileValue, and
NTileValueSize). ApplyOLAP also belongs to the OLAP category.

OLAP functions are only used in the creation of metrics. The following is an
example.

Exam ple: RunningSum


RunningSum <BreakBy={[Customer Region]}, SortBy= ([Customer
State]) >(Revenue)

BreakBy refers to the attribute or hierarchy where calculations for an OLAP


function restart. To break by an attribute or hierarchy means to restart
calculations that use OLAP, or Relative, functions when the analytical
engine reaches the next instance of the specified attribute or hierarchy.
Examples of OLAP functions include RunningStdevP, Rank, NTile, and
various expressions that calculate percent values. To break by an attribute
or hierarchy in an expression, you set the BreakBy parameter.

The RunningSum metric computes the sum of the revenue for each
Customer Region by adding the revenue for each Customer State to the
revenue of the Customer States in the rows above it and displaying the
incremented total. The BreakBy Customer Region condition causes
calculations to begin again, however, when the next Customer Region is

Copyright © 2023 All Rights Reserved 15


Fu n ct io n s Refer en ce

encountered. (Notice in the figure below that the metrics Total Revenue and
the Running Sum for Arizona are equal because the calculation for Running
Sum has restarted, since Arizona is categorized in Southwest, a different
Customer Region than Wyoming, the previous Customer State on the
report.) Because of the SortBy Customer State condition, the Customer
States are listed in ascending (alphabetical) order, as shown in the report
excerpt below.

Comparison Operators
Comparison operators allow you to compare values. Using these operators,
you can compare single values or lists of values, or compare a list to a
threshold value.

Comparison operators include < (less than), > (greater than), = (is equal to),
Between, Contains, Ends with, ApplyComparison, and so on. They are only
used to create filters, which limit report data to a subset based on your need.

Exam ple: > (Greater Than)


Revenue > 500000

Copyright © 2023 All Rights Reserved 16


Fu n ct io n s Refer en ce

In this example, the filter limits the states in your yearly income report to
those with accrued revenue greater than $500,000.

Logical Operators
Logical operators provide basic comparisons and return TRUE or FALSE
values based on the evaluation of the formula. For numeric values, 0 is
treated as FALSE, and 1 is treated as TRUE. These operators provide a
means to combine data evaluations and comparison operators into complex
expressions. These expressions, in turn, can answer questions such as
"Which of our regions produced revenue that exceeded a 'success'
threshold?"

Logical operators include And, Or, Not, and ApplyLogic, all of which can only
be used to build filters where criteria are provided for the inclusion and
exclusion of data from a report display or metric calculation.

Exam ple: And


((Revenue - Cost) > 50000) And [Sell-through Percentage] > 25

Built for the attribute State, this filter limits report data to those states where
Profit (defined as Revenue - Cost) is greater than $50,000 and the Sell-
through Percentage is greater than 25%.

Apply (Pass-Through) Functions


The terms Apply functions and Pass-through functions are interchangeable.
They both denote functions in MicroStrategy that provide access to functions
or syntactic constructs that are not standard in MicroStrategy but are
provided by various Relational Database Management System (RDBMS)
platforms. The name "Pass-through" derives from the fact that MicroStrategy
passes information to a database which then uses its own functions. (Using
the native functionality of your RDBMS via Pass-through functions requires
that you know the syntax of your particular RDBMS. That syntax is beyond
the scope of this book and will vary from RDBMS to RDBMS.) RDBMS

Copyright © 2023 All Rights Reserved 17


Fu n ct io n s Refer en ce

functions, while necessary, must be used with care, since they always
bypass MicroStrategy's parsers and validators.

There are five predefined Apply functions that can be used to replace
regular or predefined functions of the same type. The functions are as
follows:

l ApplySimple: These functions are used where simple (for example,


arithmetic) operators can be used.

l ApplyAgg: These functions are used where aggregate functions (for


example, Sum) can be used.

l ApplyRelative: These functions are used where Online Analytical


Processing (OLAP) functions (for example, Rank) can be used.

l ApplyComparison: These functions are used where comparison operators


(for example, >, =, Like and In) can be used.

l ApplyLogic: These functions are used where logical operators (for


example, AND, OR, and NOT) can be used.

With Apply functions, project designers can customize expressions in the


Attribute, Filter and Metric editors to utilize RDBMS functions that are not
provided by MicroStrategy.

MicroStrategy strongly advises against using Apply functions when


standard MicroStrategy functions can be used to achieve the same goal,
because using RDBMS functions effectively bypasses the validations and
other benefits of MicroStrategy products. Using Apply functions is
recommended only when corresponding functionality does not exist in
MicroStrategy. When you need to use an Apply function, MicroStrategy
encourages you to submit an enhancement request for inclusion of the
desired feature in a future product release.

Copyright © 2023 All Rights Reserved 18


Fu n ct io n s Refer en ce

Exam ple: ApplyCom parison Used to Check a Prom pted Date

In this example, a table in your data warehouse contains the columns Item,
Effec Date, and Term Date (as well as Revenue), as shown below:

Item Effec Date Term Date Revenue

Blouse 06/01/2007 07/30/2007 1000

Jeans 05/30/2007 06/17/2007 500

Gloves 10/01/2007 10/25/2007 150

Leather
06/15/2007 06/22/2007 750
Shoes

Winter Hat 11/01/2007 11/08/2007 900

Winter
12/01/2007 12/15/2007 2200
Boots

Each row in the table corresponds to an item that was on sale during the
time between Effec Date and Term Date. Your objective is to generate a
report that lists all items (and an associated metric that you choose) that
were on sale on a particular date your user chooses at run time. To generate
this report, first create a value prompt named Test Date that allows the user
to input a date. Next, using that prompt, create a report filter using the
Custom expression box located in the Advanced Qualification pane of the
Filter Editor, as shown below.

Copyright © 2023 All Rights Reserved 19


Fu n ct io n s Refer en ce

Even though the filter is validated when you click Validate, MicroStrategy
returns an error when the report is executed. The error results from the fact
that you are supplying the SQL engine with two attributes and a value
prompt, while MicroStrategy is expecting to compare an attribute to the
attributes Effec Date and Term Date. In effect, you have a "type mismatch"
problem.

In this case, you can use an Apply function. Instead of having MicroStrategy
test the date value prompt, you instruct your database to perform the test. It
is important to remember that you have chosen to use an Apply function only
because MicroStrategy does not have a built-in function to accomplish your
task. If an appropriate MicroStrategy function existed, you would have used
it instead of an RDBMS function, because the latter does not offer the
validating features that MicroStrategy does. (To use Apply functions, you
must know the syntax of the corresponding function or operation in the
RDBMS you are using.)

To test the date prompt, use a custom expression to pass three values to the
database for comparison: the value prompt Test Date, the attribute Effec
Date, and the attribute Term Date. All three of these values are passed to
the database using placeholders in the form of #n, where n is a positive
integer that increases by 1 for each successive item being passed, starting
with 0. The first value passed is referred to as #0, the second is #1, the third

Copyright © 2023 All Rights Reserved 20


Fu n ct io n s Refer en ce

#2, and so on. The Custom expression in the Advanced Qualification pane of
the Filter Editor depicted below shows the syntax needed for this example:

Notice that the syntax is nested. The outer portion of the expression
contains the MicroStrategy function ApplyComparison, as well as the
MicroStrategy prompt Test Date and the attributes Effec Date and Term
Date.

The inner portion of the syntax, which is contained within double quotes, is
the database operation #0 between #1 and #2. Code that is passed to
the database using an Apply function is always enclosed in quotes, and the
arguments that are passed with that code are written as placeholders in the
form of #n, with the specific forms of the passed attributes specified by the
characters after the "@" sign. In this example, [Effec Date]@ID specifies
that MicroStrategy pass the ID form of the Effec Attribute instead of the
DESC or any other form that may exist in the database. At run time, #0, #1,
and #2 are replaced by Test Date, Effec Date, and Term Date, respectively,
so that the database effectively receives the following syntax:

Test Date between Effec Date and Term Date

If the user chooses 06/16/07 as the value of Test Date at run time, the
RDBMS reads the table row by row to see if the date falls between Effec
Date and Term Date. Whenever 06/16/07 falls between Effec Date and Term

Copyright © 2023 All Rights Reserved 21


Fu n ct io n s Refer en ce

Date on a particular row, the item on that row is returned in the result set. In
this example, Blouse, Jeans, and Leather Shoes are returned. (You can
verify this result by looking at the data warehouse table shown in the
beginning of this section.) If your report is set up with Item as a row
attribute, those three items appear on your report, indicating that they (and
only they) were on sale on 06/16/07.

For additional information about Apply functions, see Apply (Pass-Through)


Functions, page 171. The syntax of each Apply function as well as examples
appear in the sections that immediately follow.

Exam ple: Test Whether Hire Date is in the Current Year

Your HR department requires a list of employees that have been hired


during the current calendar year. The following custom expression uses the
ApplySimple function to test whether the year of Hire Date is the same as
the current year:

ApplySimple ( "datepart(yy, #0)", [Hire Date]@ID) =


ApplySimple ( "datepart(yy, getdate())", [Hire Date]@ID)

Each piece of the custom expression is explained below. More detailed


information on Apply functions in general can be found in Apply (Pass-
Through) Functions, page 17. More information on ApplySimple functions,
specifically, is found in ApplySimple, page 175.

l The datepart function extracts a specified part of a given date. The first
datepart function extracts the year (as directed by yy) from the ID
attribute form of the Hire Date attribute. The ID attribute form—as opposed
to the DESC or any other attribute form—is specified by @ID.

l The placeholder, #0, stands for the argument [Hire Date]@ID that is
passed to your RDBMS. (Apply functions use your database's
computational capabilities instead of those of MicroStrategy.)

Copyright © 2023 All Rights Reserved 22


Fu n ct io n s Refer en ce

l The second datepart function extracts the year (as instructed by yy)
from the current, or system, date. The system date is obtained via the
RDBMS function getdate().

l Your RDBMS extracts the year from both the Hire Date and the system
date, with MicroStrategy passing information to it. The container that
hands the necessary function to your RDBMS is an Apply function,
ApplySimple. In other words, ApplySimple acts as an interface between
you and the database, and when the RDBMS returns both year values,
they are compared with the = operator. If the year of a particular Hire Date
element is the same as the year of the system date, the custom expression
statement evaluates as true and that Hire Date attribute element is
returned in the result set of your report. If the year of a particular Hire Date
element is different than the year of the system date, the custom
expression statement evaluates as false, and that Hire Date attribute
element is filtered out of the report.

The attribute Hire Date is enclosed in brackets. Any time you type an
attribute whose name contains one or more spaces, the attribute must be
enclosed in brackets. (The use of brackets around compound object names
is standard for many objects in MicroStrategy and is not restricted to custom
expressions and Apply functions.)

The above example used an Apply function, ApplySimple. The next example
uses ApplyComparison.

Exam ple: Custom er City = Call Center Using ApplyCom parison

You need a list of customers who live in the same city as one of your call
centers. While it is possible to generate this report with a custom expression
that does not use an Apply function, this example uses an ApplyComparison
function to demonstrate Apply functionality within the custom expression.
(For steps to create this report without the use of an Apply function, see the
Attribute-to-attribute qualifications section of the Advanced Filters chapter
of the Advanced Reporting Guide.)

Copyright © 2023 All Rights Reserved 23


Fu n ct io n s Refer en ce

The custom expression used here evaluates whether one attribute is exactly
the same as another:

ApplyComparison ("#0 like #1",


[Customer City]@DESC, [Call Center]@DESC)

Each piece of the custom expression is explained below:

l The ApplyComparison function is used with RDBMS comparison


operators, such as the like operator used in this example.

l #0 like #1 is the actual comparison, comparing the first argument, #0,


with the second argument, #1. Remember that this comparison is done by
your RDBMS—not by MicroStrategy.

l [Customer City]@DESC sets the first argument passed to your RDBMS


as the description form of the Customer City attribute, while [Call
Center]@DESC sets the second argument passed to your RDBMS as the
description form of the Call Center attribute.

The attributes Customer City and Call Center are enclosed in


brackets. Any time you type an attribute whose name contains one or more
spaces, the attribute must be enclosed in square brackets. (The use of
brackets around compound object names is standard for many objects in
MicroStrategy and is not restricted to custom expressions and Apply
functions.)

Placing a filter that uses the custom expression above on a report that lists
the Customer City, Customer, and Call Center attributes yields the results
below. (Only a portion of the report is shown. Also, the Revenue metric has
been added.)

Copyright © 2023 All Rights Reserved 24


Fu n ct io n s Refer en ce

Notice that the custom expression qualification filter accomplished the goal
of returning only data that satisfies the criterion that the Customer City
attribute is the same as the Call Center attribute.

Function Parameters
Parameters determine how functions perform calculations. Any function,
whether standard or user-defined, can have parameters, which are
contained within angle brackets <> in an expression. If more than one
parameter is used, they are separated by commas.

Function parameter notations are only displayed in the Developer interface


if the parameter settings are changed from the default and you have set
your View option to Show Function Parameters.

You define parameters in the Function Name Parameters dialog box, which
displays the tabs Parameters, Break By, and Sort By. For steps on how to
access this dialog box and how to set function parameters with the Insert
Function Wizard, see Accessing and Modifying Function Parameters, page
29.

Copyright © 2023 All Rights Reserved 25


Fu n ct io n s Refer en ce

Since every function object has parameters, the Parameters tab is always
displayed. If a function has additional parameters, such as BreakBy and
SortBy, the related tabs are displayed accordingly. The following
subsections discuss the three tabs in more detail:

l Common Parameters, page 27

l BreakBy and SortBy Parameters, page 27

The details of each function are covered in this guide, including a listing and
description of each parameter that is available for the function. All
parameters are listed within angle brackets <> as part of the function syntax.
To review the details on the parameters available for each function, review
the functions provided in:

l Chapter 2, Standard Functions

l Chapter 3, Operators

l Chapter 4, Plug-In Package Functions

In this guide, lists of attributes, metrics, values, parameters, etc. within a


function are separated by commas. Your separator may vary depending on
your number and date format locale. For example, the separator is a comma
(,) in English and a semicolon (;) in Geman.

Copyright © 2023 All Rights Reserved 26


Fu n ct io n s Refer en ce

Common Parameters
There are three common Parameter settings for a function object:

l Distinct: is a TRUE/FALSE parameter that allows you to use all values or


only the unique values in the calculation.

l Fact ID: forces the calculation to take place on a fact table containing the
Fact_ID.

l NULL: is a TRUE/FALSE parameter that determines if the NULL value can


be used in the calculation.

Not all these settings apply to every function. In general, all group-value
functions display the FactID Parameter setting. OLAP functions do not have
any of these Parameter settings, but they may have BreakBy or SortBy
parameters.

BreakBy and SortBy Parameters


In addition to the Parameters settings, many functions have BreakBy or
SortBy parameters, each of which has its own individual settings:

l BreakBy: The logical level where the calculation of values for an


expression restarts. To break by an attribute or hierarchy means to restart
counting values for expressions that use relative functions. Examples of
relative functions are RunningStdevP, Rank, NTile, and expressions that
calculate rank or percent values. The break by level must at the same level
of aggregation or a higher level of aggregation used for the expression
itself.

For example, in the report shown below the Rank by Value metric ranks
the revenue values. The Rank function for this metric uses a BreakBy
of the Customer Region attribute, which means the rank calculation is
restarted for each customer region. This ensures that the revenue is
ranked by customer region, rather than ranking all of the revenues

Copyright © 2023 All Rights Reserved 27


Fu n ct io n s Refer en ce

together across customer regions. While ranking all the revenues


across customer regions can be useful, this report uses the BreakBy
parameter to focus on revenue comparisons within each customer
region.

l SortBy: The order of the return values of an expression in relation to the


order of the value or metadata object given. A sort by includes whether to
sort in ascending or descending order, and which metadata object to sort
by. Sort by may also be performed on the value of the subexpression,
which is the input argument.

For example, in the report shown below the FirstInRange metric returns
the first profit value in a list of profit values. The FirstInRange
function for this metric uses a sort by of the Customer State attribute,
which means the first value for each customer state is returned.

Copyright © 2023 All Rights Reserved 28


Fu n ct io n s Refer en ce

OLAP functions often include BreakBy and SortBy parameters. For example,
Rank has a BreakBy parameter, and MovingAvg has a SortBy parameter.

A few group-value functions (First, Last, IRR, and NPV) are also defined by
the SortBy parameter. The First and Last functions are used effectively to
calculate subtotals (see Subtotal Expressions, page 55).

For example, an inventory report lists the on-hand supply for each day. The
report subtotals are the last day's inventory. Creating a user-defined
subtotal that uses the Last function provides the last day inventory subtotal.
If the SortBy parameters of the function are not set to sort by Day, the
function may not provide the correct answer.

Accessing and Modifying Function Parameters


MicroStrategy Developer provides different methods for accessing and
modifying function parameters. You can access and modify function
parameters from the following interfaces:

l Insert Function Wizard: This interface is used to help guide you in the
initial inclusion of a function in an expression for a MicroStrategy object.
The Insert Function Wizard can be used to build a function and add it to an
expression for metrics, attributes, facts, subtotals, and transformations.

Copyright © 2023 All Rights Reserved 29


Fu n ct io n s Refer en ce

For more information, see Adding Functions to Expressions with the Insert
Function Wizard, page 57.

l Function Name Parameters dialog box: This interface is used to modify


the parameters of a function that has been added to an object expression
and validated.

To Access and Modify Function Parameters with the Insert Function


Wizard

1. Open an object editor for a MicroStrategy object that can include


functions in its expression.

For steps to access the Insert Function Wizard from the different
object editors, see the MicroStrategy online help and search for "Steps
to access the Insert Function Wizard". You can also see the section
Using Functions in Expressions, page 35 below that discusses the
different types of expressions in MicroStrategy.

2. Click the Insert Function button, labeled as f(x) on the expression


toolbar.

The Insert Function Wizard opens.

3. Use the Next and Back buttons to step through the pages of the Insert
Function Wizard. Each page allows you to modify different function

Copyright © 2023 All Rights Reserved 30


Fu n ct io n s Refer en ce

parameters.

The pages that you see depend on the function that you select.

To Access and Modify Function Parameters with the Function Name


Parameters Dialog Box

This functionality is available in any editor in Developer where functions are


used in expressions. For more information, see the following sections:

l Metric Expressions, page 36

l Attribute Form Expressions, page 45

l Custom Group Expressions, page 49

l Fact Expressions, page 51

l Filter Expressions, page 53

l Subtotal Expressions, page 55

l Transformation Expressions, page 56

1. Insert a function into an object expression and validate the expression.

You can insert a function by writing the name of the function and all
required parameters into the expression. You can also insert a function
using the Insert Function Wizard (see the procedure To Build an
Expression Using the Insert Function Wizard, page 57).

2. Highlight the function name, for example RunningSum, within a


validated expression in the expression box.

3. Right-click the function name and select function name parameters,


as demonstrated in the image below.

Copyright © 2023 All Rights Reserved 31


Fu n ct io n s Refer en ce

The Function Name Parameters dialog box opens. All parameter


tabs for the selected function are available, and settings editable,
from this dialog. This example uses the RunningSum function.

Examples of Function Parameter Effects


The following examples briefly illustrate the impact of parameters on
function execution.

Exam ple 1: Distinct Param eter


Count<Distinct=True>(Order)
Copyright © 2023 All Rights Reserved 32
Fu n ct io n s Refer en ce

In this metric, you modify the default parameter setting to Distinct=True and
retrieve a count of only the unique Orders.

Exam ple 2: RunningSum


RunningSum<BreakBy={Quarter}, SortBy=(Region)>(Revenue)

This metric is defined to display the running sum of revenue on a quarterly


basis, sorted by region in ascending order. For another RunningSum
example and its report, see OLAP (Relative) Functions, page 14.

Arguments
Arguments are the input data used in the calculation of a function.
Arguments can be numbers, text, or logical values (such as TRUE or FALSE)
as well as constants (such as 1, 2, 3, or NULL). They can be lists of values
or variables referencing lists of values.

Arguments in MicroStrategy are most often references to lists of values. In


function syntax, the arguments are enclosed in parentheses (). If the
argument is a reference to a MicroStrategy object, and the object name is
alphanumeric or contains multiple words, it is also contained in brackets [ ].
Depending on the function selected and the object being created, in a
MicroStrategy environment the input could comprise one or more of the
following objects:

l Attributes: Attributes are most often used to group fact data. They are
included in reports to define the level of detail. Typically non-numeric,
some common examples of attributes are Year, Category, and Region.

l Facts: Facts are the most commonly used input for metrics. They are
numerical lists obtained from specific columns in a fact table. Examples of
facts include Units Sold, Units Received, and Discount.

l Metrics: Metrics represent calculations performed on data and can


themselves be used as input for further calculation by a function.

Copyright © 2023 All Rights Reserved 33


Fu n ct io n s Refer en ce

Examples of metrics include Percent Growth, Profit Margin, and Sell-


through Percentage.

l Columns: Column data is used when creating attribute form expressions


and fact expressions. The expressions for these objects define how
column data is retrieved from the warehouse. Examples of columns
include TOT_DOLLAR_SALES, TOT_COST, and CUST_CITY_ID.

In this guide, lists of attributes, metrics, values, parameters, etc. within a


function are separated by commas. Your separator may vary depending on
your number and date format locale. For example, the separator is a comma
(,) in English and a semicolon (;) in German.

For an in-depth discussion of attributes, facts, and metrics, see the


Advanced Reporting Help.

Using Prompts for Arguments


Prompts can be used to provide the value for an argument in a function,
which allows a user to determine part of the function definition when a report
is executed. Arguments that expect a single value are the most common
arguments to use prompts on. For example, the function NTileSize (see
NTileSize, page 271) has the following syntax:

NTileSize <Ascending, BreakBy> (Argument, Size)

The two arguments for this syntax are:

l Argument is a metric representing a list of values to be distributed in


buckets.

l Size is a positive integer that designates the number of elements per


bucket.

The argument Size is a good candidate to use a prompt for, since it expects
a single value. Using a prompt to provide the value for Size allows a user to
determine how many elements should be included in each NTile bucket. This

Copyright © 2023 All Rights Reserved 34


Fu n ct io n s Refer en ce

is a more flexible reporting solution than defining a static value for the
argument that is always used for the calculation.

To include a prompt in a function expression, you can use the following


syntax:

?[Prompt Name]

The Prompt Name is the name of the prompt object. For example, you can
have the following definition:

NTileSize([Total Revenue], ?[NTileValue Prompt])

In the syntax shown above, NTileValue Prompt is the name of a value


prompt that supplies the size for the NTileSize function.

When prompts are created, you can choose whether answering the prompt
is optional or required. Since arguments are required for a function to work
properly, it is a good practice to define prompt answers as required if the
prompt is going to be used in a function expression.

Many of the financial functions (see Financial Functions, page 347) use
arguments that expect a single value, and thus are good candidates for
using functions to provide their values. For example, the function Coupdays
(see Coupdays (Coupon Period, Number of Days with Settlement), page
353) includes a Frequency argument which can accept the value of 1, 2, or
4 to determine the number of coupon payments per year. You could use a
value prompt for the Frequency argument to prompt the user to enter the
frequency of the coupon payments.

Using Functions in Expressions


Functions are the basis for many MicroStrategy objects. Some of the objects
they are used to create includes:

l Metric expressions

l Attribute form expressions

Copyright © 2023 All Rights Reserved 35


Fu n ct io n s Refer en ce

l Consolidation expressions

l Custom group expressions

l Fact expressions

l Filter expressions

l Subtotal expressions

l Transformation expressions

l Derived elements

l Derived attributes

This section explores the various roles of functions for each type of object
and how to access the expression builder in each case.

Metric Expressions
Metrics are MicroStrategy objects that represent calculations performed on
data. You can define metrics by using the available functions to analyze your
data and determine business measures.

Formula and dimensionality are the two important components in a metric.


While all metrics have a formula, not all of them have dimensionality.

l Formula: Is a mathematical expression using one or more functions,


applied to the data to be used in the calculation (facts, attributes,
constants, or metrics). In SQL, the formula commonly becomes part of the
SELECT clause of the SQL command.

You can re-use the same formula in multiple metric definitions. This type
of formula is called a base formula, which can contain arithmetic
operators, attributes, facts, group functions, and non-group functions. A
base formula does not have dimensionality (see below). For more
information on base formulas, see the Basic Reporting Help.

l Dimensionality: determines the attribute level at which a metric is


calculated. After deciding on the target (the attribute), in dimensionality

Copyright © 2023 All Rights Reserved 36


Fu n ct io n s Refer en ce

you can further define filtering and grouping involved in the metric. All
metrics, by default, calculate at the report level.

Other optional components of a metric include condition (filter) and


transformation. For the purposes of this book, we only discuss formula and
dimensionality related to the use of functions. For information on all metric
components, including additional information and examples of level
metrics, conditional metrics, and transformation metrics, see the
Advanced Reporting Help.

There are two types of metrics:

l Simple metric: has a formula and dimensionality (level). It can stand alone
or be used as a building block for a compound metric. A simple metric
must use at least one group-value function, such as Sum or Avg. It can
also contain a non-group function or arithmetic operator, in addition to the
required group function, for example, Sum(Revenue - Cost){~+};
however, the outermost formula must be a group function.

l Compound metric:isa combination of expressions that, through the use of


functions, are themselves metrics. In other words, a compound metric is
made of more than one complete metric. Any metric that is not a simple
metric is a compound metric by default. For example, all arithmetic
functions that are used as the root to connect two metrics yield compound
metrics.

A compound metric cannot have dimensionality placed on the entire


metric, although dimensionality can be set separately on each of its
component metrics.

A quick way to check whether a metric is simple or compound is through the


Metric Editor, where you can click the Subtotals/Aggregation tab and check
if the Allow Smart Metric option is enabled. If it is, then it is a compound
metric; if not, it is a simple metric.

The following three types of functions can be used to build simple and
compound metrics:

Copyright © 2023 All Rights Reserved 37


Fu n ct io n s Refer en ce

l Single-value functions

l Group-value functions

l OLAP functions

The optional condition (filter) component of a metric can contain logical and
comparison operators. See the Filter Expressions subsection for details.

While the single-value and group-value functions are used to create both
simple and compound metrics under different circumstances (see examples
to follow), the OLAP functions always yield compound metrics, due to their
unique characteristics (see OLAP (Relative) Functions, page 14).

Examples of Dimensionality in Metrics


As mentioned previously, all metrics have a formula, but not all metrics have
dimensionality. The following examples and diagrams illustrate the
formation of simple and compound metrics, as well as formula and
dimensionality.

Exam ple 1: Sim ple Metric with Dim ensionality at the Report Level
Avg(Revenue) {~+}

In this example, the expression is Avg on the fact Revenue. Together they
make up the base formula. This simple aggregation metric has
dimensionality, which is indicated by {~+}, meaning that the metric is

Copyright © 2023 All Rights Reserved 38


Fu n ct io n s Refer en ce

calculated at the lowest level on the report. For example, if a report contains
revenue by year and month, the numbers are calculated to reflect monthly
sales data. If month was removed from the report, the metric would
automatically be calculated at the new report level, which would reflect
yearly sales data.

All group-value functions are aggregation functions, which, when used


alone, yield simple metrics.

Exam ple 2: Sim ple Metric with Dim ensionality at Year Level
Sum(Cost) {~ +,year +}

Copyright © 2023 All Rights Reserved 39


Fu n ct io n s Refer en ce

In this example, the expression is Sum on the fact Cost. Together they make
up the base formula. This simple aggregation metric has dimensionality.
However, unlike in Example 1, dimensionality is set at the level of the
attribute Year, indicated by {Year +}. This means that if a report contains
cost by year and month, the numbers are calculated to reflect yearly cost
data.

Exam ple 3: Dim ensionality for Com pound Metrics


Avg(Revenue){~ +}/ Sum(Revenue) {~ +}

Copyright © 2023 All Rights Reserved 40


Fu n ct io n s Refer en ce

Dimensionality of compound metrics is defined by the other metric


definitions that are combined to create a compound metric. In this example,
the root Division (/) has two children, Avg(Revenue) and Sum(Revenue),
both of which are simple metrics themselves, and each of which has its own
dimensionality. The whole expression itself is a compound metric because it
uses two metrics and does not have its own dimensionality.

Accessing Metric Functions


You can access functions to create metrics in several ways. You can use the
Metric Editor when creating a new metric in a project. To create a derived
metric, which is a metric based on the existing data in a report, use the
options from within a report to insert a new metric.

You can also create metrics in Command Manager. For more information on
this method, see the Advanced Reporting Help.

Metric Editor

The Metric Editor is used to create new metrics and edit existing metrics in
MicroStrategy. The interface allows you to build metric expressions and

Copyright © 2023 All Rights Reserved 41


Fu n ct io n s Refer en ce

validate them.

To Access the Metric Editor Using Developer

1. Log in to a project.

2. In the MicroStrategy Developer File menu, point to New > Metric. The
New Metric dialog box is displayed.

3. Choose a Metric template and click OK. The Metric Editor displays.

4. Build the metric expression, accessing the functions in one of the


following ways:

l Expand the Functions and Operators folder using the drop-down list
or shortcut list in the Object Browser pane. Then expand the
Functions, Operators, or Plug-In Packages folder to access the
various categories of functions and operators.

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required metric syntax directly in the
Enter your formula here box.

You can also edit existing metrics by using the Metric Editor. To
access the editor, select the appropriate metric in the folder list,
object browser, or report view. Then right-click and select Edit from
the shortcut menu. The Metric Editor opens with the selected metric
loaded.

To Access the Metric Editor Using Web

1. Log in to a project.

2. From the MicroStrategy Web home page, click Create Metric.

Copyright © 2023 All Rights Reserved 42


Fu n ct io n s Refer en ce

3. In the pane below, select the function to use to calculate data in the
metric. You can narrow the list of functions displayed in the pane by
doing one of the following:

l To search for the function by name, type the function's name in the
search field.

l Choose a function category from the drop-down list, such as Math


Functions or Financial Functions. The pane is updated to include only
the functions that belong to the selected category.

4. The Function Editor opens, with different options available depending


on the type of function you selected above:

l If you selected a grouping function, such as Sum, Average, First, or


Maximum, you are presented with options to define the metric's
expression, as well as optional components such as the level,
condition, and transformation. Perform the following steps:

1. Define the metric's expression by doing one of the following:

l To specify the expression by typing the name of an object,


type the name of the object in the Expression field. As you
type, matching objects are displayed in a drop-down list. You
can click an object or continue to type. You can type multiple
objects, such as Revenue-Profit.

l To specify the expression by choosing an object, click the


Browse icon. The Select an Object dialog box opens. Navigate
to and select an object, or search for the object.

2. You can further define the metric by adding a level, condition,


and transformation.

Copyright © 2023 All Rights Reserved 43


Fu n ct io n s Refer en ce

l If you selected a non-grouping function, such as data mining,


date, OLAP, and ranking functions, you are presented with
options to define the input values (called arguments) for the
function, as well as any parameters you can use to determine
the behavior of the function. For example, the NTile function
has two parameters, Ascending and Tiles. Ascending controls
whether the NTiles are ordered in ascending or descending
order, while Tiles sets the number of splits. To view a list of
the arguments and parameters for the function, click Details at
the bottom of the dialog box.

Perform the following steps:

1. For each argument listed, type a value or click the


Browse icon to find the metric, fact, prompt, or other
compatible object to use as input values of the function.

2. For each parameter listed, type a value or select the


parameter value from the drop-down

5. Click Save. For additional steps to define metrics using Web, see the
MicroStrategy Web Help .

Creating Derived Metrics

You create derived metrics based on objects already present in the report.

To Create Derived Metrics

1. Log in to the project.

2. Begin to create the derived metric:

l Using Developer, from the Insert menu in the Report Editor, select
New Metric. Or, right-click above a metric heading in the Report
Grid, point to Insert > New Metric. The Input Metric Formula dialog

Copyright © 2023 All Rights Reserved 44


Fu n ct io n s Refer en ce

box is displayed.

l Using MicroStrategy Web from the Data menu in the Report Editor,
select Insert New Metric. The Metric Editor is displayed.

3. Build a metric using the available report objects.

Attribute Form Expressions


Attribute forms are identifiers or descriptors of an attribute, such as ID,
Name, and Address. These units are part of an attribute, for example,
Customer. Attribute forms are defined by at least one expression, and these
expressions act on column data and can contain functions. The types of
attribute form expressions are as follows:

l Simple

l Implicit

l Derived

l Heterogeneous

For more information on these types of attribute forms, see the Advanced
Reporting Help.

In the context of MicroStrategy functions, this book discusses derived


expressions. A derived expression can only use single-value functions, and
arguments that are used in the expression are columns. See the examples
described below.

Example 1: Subtraction ( - )
(Year(CurrentDate()) - Year([HIRE_DATE]))

The attribute form Employee Experience is defined by the above expression


using the simple mathematical operator, subtraction.

Copyright © 2023 All Rights Reserved 45


Fu n ct io n s Refer en ce

This example can be found in the MicroStrategy Tutorial project in the


following folder: MicroStrategy Tutorial/Schema
Objects/Attributes/Geography.

Example 2: InitCap
InitCap([CUST_LAST_NAME])

Text data is typically in all upper-case or all lower-case letters. This example
shows that for the attribute form of customer's last name, you can use the
single-value function, InitCap, to make the first letter capitalized and all
other letters in lower case.

Example 3: ApplySimple
ApplySimple("Datediff(YY,#0,getdate())", [BIRTH_DATE])

The attribute form, Age, can be defined by using the single-value function,
ApplySimple.

l For all Apply functions, do not use a group for the attribute form
expression. Use a single form because form groups are ignored by the
Analytical Engine. For example, you cannot use Customer@Name, where
Name is a form group defined as the customer's first name, middle name,
and last name.

l The syntax of apply functions is database-specific. For more information,


see Internal Functions, page 169.

To Access Attribute Form Expressions

Fo r a N ew At t r i b u t e

1. From the MicroStrategy Developer File menu, point to New > Attribute.
The Attribute Editor opens three dialog boxes, if the cascading dialog

Copyright © 2023 All Rights Reserved 46


Fu n ct io n s Refer en ce

box option is enabled in the Developer Preference (as it is by default).


The three dialog boxes are New Attribute, Create New Attribute Form,
and Create New Attribute Form Expression. The Create New Attribute
Form Expression dialog box is where functions and operators are used.

2. Build your expression by using the functions in one of the following


ways:

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required expression syntax directly in
the Enter your formula here box.

Fo r an Exi st i n g At t r i b u t e

1. To access the editor, select the attribute in the folder list, object
browser, or report view and right-click and select Edit.

2. Select an attribute form and click Modify. The Modify Attribute Form
dialog box displays.

To add a new form to the existing Attribute, click New. This


automatically opens the New Attribute Form Expression dialog box.

3. Select the expression you want to edit and click Modify.

To add a new expression to the existing form, click New. This


automatically opens the New Attribute Form Expression dialog box.

4. The Modify Attribute Form Expression dialog displays with the selected
expression loaded.

5. Create or edit the expression, accessing the functions in one of the


following ways:

Copyright © 2023 All Rights Reserved 47


Fu n ct io n s Refer en ce

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter/edit the function name and all required expression syntax in the
Enter your formula here box.

Consolidation Element Expressions


Consolidations enable you to group attribute elements for use in a report,
without changing the structure of your metadata or your warehouse
definition. The elements contained in a consolidation are called
consolidation elements (CEs). Only single-value functions can be used in
the definition of a consolidation element as well as calculations between
consolidation elements. A consolidation element expression defines how the
attribute elements are calculated.

Only the basic mathematical operators (+, -, *, /) can be used through


MicroStrategy Developer to define consolidation elements. Examples of
consolidations, using these operators, are as follows:

l CE01 = {Region = North-East}

l CE02 = {Region = Mid-Atlantic}

l CE03 = ({CE01} – {CE02})/{CE02}

Other single-value functions can also be used for consolidation elements,


but only through the SDK.

The following examples demonstrate definitions using functions and


calculations:

l CE04 = Ln({Region = North-East})

l CE05 = Ln({Region = Mid-Atlantic})

l CE06 = Abs({CE04} – {CE05})

Copyright © 2023 All Rights Reserved 48


Fu n ct io n s Refer en ce

For more information on consolidations, see the MicroStrategy Advanced


Reporting Guide.

To Access the Consolidation Element Expressions

1. In the MicroStrategy Developer File menu, point to New >


Consolidation. The Consolidation Editor opens.

2. Double-click Click here to add new consolidation element.

3. The New Consolidation Element pane is enabled. Build the expression


for the new element.

You must drag and drop attributes into the Enter your expression here
box. Only the operators can be typed directly in the box.

Custom Group Expressions


A custom group is an object that can be placed on a template and is made up
of a collection of elements called custom group elements. A custom group
can group attribute elements in a way that is not defined in the data
warehouse. You can create relationships between the attribute and the
custom group. A custom group expression defines how the elements in the
custom group are calculated.

A custom group can organize attribute elements through:

l Attribute qualification

l Set qualification

l A report

l A filter

l Banding

l Advanced qualification

Copyright © 2023 All Rights Reserved 49


Fu n ct io n s Refer en ce

For more information on custom groups, see Custom Groups and


Consolidations in the MicroStrategy Advanced Reporting Guide.

When you define custom group elements through advanced qualification,


you can use two types of functions:

l Logical functions

l Comparison functions

See the following examples.

Example 1: Subtraction ( - )
([Unit_Profit] - [Unit_Cost]) > 500

Example 2: And
([Units Sold] > 500) and ([Unit Profit] > 1000)

To Access the Custom Group Element Expressions

1. In the MicroStrategy Developer File menu, point to New > Custom


Group. The Custom Group Editor opens.

2. Double-click Double-click here or drag an object from the object


browser to add a custom group element.

3. Enter a name for the new element and double-click Add Qualification.

4. In the Custom Group Options pane, select Add an Advanced


qualification and click OK.

5. The Advanced Qualification pane opens. This is where the expression


is built. The functions are accessed in one of the following ways:

Copyright © 2023 All Rights Reserved 50


Fu n ct io n s Refer en ce

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required expression syntax directly in the
Enter your formula here box.

Fact Expressions
Facts are objects created by and shared between MicroStrategy users. They
relate numeric data values from the data warehouse to the MicroStrategy
reporting environment. A fact expression defines how a fact is calculated.
The fact expression is part of the Fact Definition component of a fact
structure. You can use functions to create fact expressions, and arguments
that are used in the expressions are columns.

Facts can be defined as:

l Implicit

l Derived

l Heterogeneous

For more information on facts and fact structure, see the MicroStrategy
Project Design Guide.

In the context of MicroStrategy functions, this book discusses derived fact


expressions.

Derived fact expressions can only use single-value functions, including


simple arithmetic operators (+, -, /, *). See the following two examples.

Example 1: Subtraction ( - )
([UNIT_PRICE] - [UNIT_COST])

The fact Unit Profit is defined using the table columns Unit_Price and Unit_
Cost and a simple mathematical operator, subtraction.

Copyright © 2023 All Rights Reserved 51


Fu n ct io n s Refer en ce

Example 2: Multiplication ( * )
([QTY_SOLD] * ([UNIT_PRICE] - DISCOUNT))

The fact Revenue is defined using three table columns and two arithmetic
operators, subtraction and multiplication.

Both examples can be found in the MicroStrategy Tutorial project in the


following folder: MicroStrategy Tutorial/Schema Objects/Facts.

To Access Fact Expressions

Fo r a N ew Fact w i t h an Exp r essi o n

1. In the MicroStrategy Developer File menu, point to New > Fact.

2. The Expression page is where the expression is built. The functions are
accessed in one of the following ways:

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Type the function name and all required expression syntax directly in the
Enter your formula here box.

Fo r an Exi st i n g Fact

1. Select an existing fact in the MicroStrategy Developer main screen.


Then right-click and select Edit. The Fact Editor displays with the
selected fact loaded.

2. Click New to add a new expression to the fact, or select an existing


expression and click Modify. The Create New Fact Expression or
Modify Fact Expression page displays.

3. Build an expression by using functions in one of the following ways:

Copyright © 2023 All Rights Reserved 52


Fu n ct io n s Refer en ce

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required expression syntax directly in the
Enter your formula here box.

You can use either the Fact Editor or the Fact Creation Wizard to create
facts; however, only the Fact Editor allows you to use advanced
expressions to define the fact.

Filter Expressions
A filter specifies the conditions that data must meet to be included in the
report results. In SQL, a filter is specified after the WHERE clause. A filter
can be a report object, that is, a report filter, a report limit, or a view filter,
that restricts the data returned or the display or view of data on a report. For
detailed information on report filters, see the Advanced Reporting Help .

A filter can also be a metric qualifier created using custom expressions


employing functions. It is used as the optional condition component of a
metric. You can create this type of filters by using the Advanced
Qualification dialog box within the Filter Editor. Only the following types of
functions can be used in filter expressions:

l Logical operators

l Comparison operators

Single-value functions can be used at the sublevel in a filter expression, as


long as the root node is a logical or comparison function (see Example 1).

Example 1: Greater Than ( > )


((Revenue - Cost) > "5000")

This example uses a simple comparison operator to create a filter to limit the
display of profit to values greater than $5,000.

Copyright © 2023 All Rights Reserved 53


Fu n ct io n s Refer en ce

You can achieve the same result by using a set (metric) qualification on a
compound metric (such as the one in the example defined as Revenue -
Cost). The custom filter expression is used here for illustration purposes. It
is up to you which method you prefer to use.

Example 2: ApplyComparison
ApplyComparison("#0 between #1 and #2", ?[Value Prompt Date],
[Order Date]@ID, [Ship Date]@ID)

ApplyComparison is commonly used to create custom filters. In this


example, the filter compares a user-entered date to see if it is between the
Order_Date and the Ship_Date.

To Access an Advanced Filter Qualification

1. In the MicroStrategy Developer File menu, point to New > Filter. The
Filter Editor is displayed.

2. In the Filter Definition pane, double-click Double-click here to add a


qualification or drag an object from the Object Browser. The
Filtering Options pane is displayed.

3. In the Filtering Options pane, select the Add an Advanced


qualification option and click OK. The Advanced Qualification pane is
displayed.

4. Select Custom Expression from the Option list. Then use the Custom
Expression box to build and validate your custom filter. Access the
functions in one of the following ways:

l Expand the Functions and Operators folder using the drop-down list
or folder list. Then expand the Functions, Operators, or Plug-In
Packages folder to access the various categories of functions and
operators.

Copyright © 2023 All Rights Reserved 54


Fu n ct io n s Refer en ce

l
Click (Insert Function) in the Definition pane. The Insert Function

Wizard opens.

l Enter the function name and all required metric syntax directly in the
Enter your formula here box.

Subtotal Expressions
Subtotals allow you to dynamically control the computation and display of
report data within desired groupings. Subtotals are applied to report metrics
to calculate totals and for dynamic aggregation.

The standard predefined subtotal functions, which are automatically


available for use with every metric and report, are simple aggregate
functions that satisfy many subtotaling requirements. If they do not answer
your particular needs, you can create a user-defined subtotalusing the
Subtotal Editor or through the SDK. User-defined subtotals allow you to
develop your own subtotals, using single-value functions or group-value
functions.

Both predefined and user-defined subtotals can be applied to reports from


the Subtotals/Aggregation tab in the Metric Editor.

For more information on subtotals and the procedures for creating and
applying them, see the Reports chapter of the Advanced Reporting Help or
the MicroStrategy online help.

Example: Division ( / )
Sum(Sum(x*[Units Sold]){Year}/Sum([Units Sold]){Year}){}

To Access Functions in the Subtotal Editor

1. Log in to a project.

2. In the MicroStrategy Developer File menu, point to New and then select
Subtotal. The Subtotal Editor displays.

Copyright © 2023 All Rights Reserved 55


Fu n ct io n s Refer en ce

3. The Subtotal Editor is very similar to the Metric Editor. To access the
functions used to create a new subtotal, you can do one of the
following:

l Expand the Functions and Operators folder using the drop-down list
or shortcut list in the Object Browser pane. Then expand the
Functions, Operators or Plug-In Packages folder to access the
various categories of functions and operators.

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required subtotal syntax directly in
the Enter your formula here box.

Transformation Expressions
Transformations are schema objects that use business rules to compare
values at different time periods. A typical example of this type of analysis is
a TY/LY comparison (This Year versus Last Year).

Transformations are schema objects; therefore, you must have the


appropriate privileges to create or modify them.

There are two types of transformations: expression-based and table-based.


Single-value functions can be used in expression-based transformations,
and specifically in the definition of member expressions. These expressions
define how (and from where) the information is retrieved for the
transformation of the specified attribute.

For more information on transformations and their components, see the


Advanced Reporting Help or the MicroStrategy online help.

Copyright © 2023 All Rights Reserved 56


Fu n ct io n s Refer en ce

To Access Functions in Transformations

1. In the MicroStrategy Developer File menu, point to New >


Transformation. The Transformation Editor is displayed. The Select
Member Attribute dialog box also opens.

2. Select the attribute on which to base the transformation and click OK.
The Expression Editor opens.

3. Build an expression for the transformation of the selected member


attribute, accessing functions in one of the following ways:

l
Click (Insert Function) in the Definition pane. The Insert Function

wizard opens.

l Enter the function name and all required expression syntax directly in
the Enter your formula here box.

Adding Functions to Expressions with the Insert Function


Wizard
The Insert Function Wizard is available wherever functions are used. It
guides you through the process of selecting a function, choosing the data on
which the function acts, and setting the available parameters.

To Build an Expression Using the Insert Function Wizard

For detailed information on each page of the Insert Function Wizard, see the
MicroStrategy online help and search for "Using the Insert Function
Wizard."

1. Click the Insert Function button to access the wizard. The Select

Function page of the Insert Function Wizard is displayed.

Copyright © 2023 All Rights Reserved 57


Fu n ct io n s Refer en ce

2. Select a function and click Next. The Arguments page opens.

3. Enter the values or names of the arguments you want to add or browse
for the arguments:

l Enter the appropriate values or name of the arguments into the


available boxes.

l Click (the Browse button). The Open dialog box opens, which is a

standard Windows dialog box for file selection.

Select the argument on which the function acts. Click Open to select
the argument and return to the Insert Function Wizard.

4. Click Next. The Parameters page is displayed (if applicable).

Copyright © 2023 All Rights Reserved 58


Fu n ct io n s Refer en ce

For group-value metrics such as Count, Min, and Max, standard


parameters (Distinct, NULL, and FactID) display together on the only
page available, called Parameters. The default for FactID is (Nothing),
meaning that the calculation searches for the input argument from the
lookup table. Otherwise, make a selection from the pull-down list to
force the calculation to look in another table.

5. Set the values of the parameters.

6. Define the SortBy and BreakBy parameters in their separate windows, if


applicable.

7. Click Finish. The expression built through the Insert Function Wizard
displays in the appropriate editor.

Copyright © 2023 All Rights Reserved 59


Fu n ct io n s Refer en ce

Parameter values are displayed only if you have set your view to Show
Function Parameters and have modified a parameter from its default
setting.

How MicroStrategy Processes Functions


MicroStrategy Intelligence Server has an engine component, which
comprises the following:

l SQL Engine: Generates the SQL and associated logic for functions
performed by the database, and communicates with the Analytical Engine
as necessary.

l Query Engine: Sends the SQL generated by the SQL Engine to the data
warehouse for execution.

l Analytical Engine: Extends the capability of the system beyond what the
RDBMS provides. For example, it performs complex calculations on a
result set returned from the data warehouse, such as statistical and
financial functions, subtotal calculations on the result set, metric
calculations that are not or cannot be performed using SQL, such as
complex functions, and so on.

While this extends the capabilities of the RDBMS that you are using,
calculations that require the Analytical Engine can require additional
system resources and processing time. To determine if a function is
supported by your RDBMS or will be evaluated by the Analytical Engine,
review the function support listed in Appendix A, MicroStrategy and
Database Support for Functions.

Types of Function Processing


Functions supported by the Intelligence Server are of three types:

l Those that can be processed only by the Analytical Engine, such as


finance functions.

Copyright © 2023 All Rights Reserved 60


Fu n ct io n s Refer en ce

If the Analytical Engine does not support a given function, a compound


metric containing the function cannot be smart metric enabled. This is
because smart metrics change the default order of metric evaluation and
only the Analytical Engine can support such a change.

l Those that can be processed either by the Analytical Engine or by the


database.

If the database can perform the calculation, the SQL Engine sends the
instructions to the database; otherwise, the Analytical Engine processes
the task.

How Intelligence Server Uses Functions


Recall that there are several categories of functions recognized by
Intelligence Server. These function types include group-value, single-value,
and OLAP functions. Within these categories are functions supported by
only the Analytical Engine, only the database, or by both the engine and the
database. The SQL generated to process the request differs depending on
what processes the request. The SQL syntax also differs depending on the
database used, when the database supports the function.

The following subsections explore through examples of how the various uses
of functions result in different SQL syntax. All of these examples use the
functions in the context of metrics.

Most of these examples (except where noted) can be recreated using the
objects in the MicroStrategy Tutorial. Tutorial data is stored in a Microsoft®
Access database.

Using Group-Value Functions


The computation of group-value functions is done by either the Intelligence
Server or the database depending upon the function used and support
available. The following examples discuss how MicroStrategyperforms the
group-value computations by providing the SQL syntax for specific
situations.

Copyright © 2023 All Rights Reserved 61


Fu n ct io n s Refer en ce

Group-Value Functions in Simple Metrics


This subsection contains two examples that illustrate the processing of
group-value functions. Each example contains two reports, the first one
showing the SQL for a function supported by the database and the second
one by the Analytical Engine.

Exam ple 1: Sum (Revenue) vs. AvgDev(Revenue)

Consider a simple report, Report 1A, where the attribute Region is placed on
the row axis and a simple metric defined as M1A=Sum(Revenue){~} is on
the column axis. This report shows the sales for each region. The database,
in this case Microsoft Access, supports the function Sum. The following SQL
is generated:

l Report 1A (SQL Group-value function) - Microsoft Access

select a12.[REGION_ID] AS REGION_ID,


max(a13.[REGION_NAME]) AS REGION_NAME,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CITY_CTR_SLS] a11,
[LU_CALL_CTR] a12,
[LU_REGION] a13
where a11.[CALL_CTR_ID] = a12.[CALL_CTR_ID] and
a12.[REGION_ID] = a13.[REGION_ID]
group by a12.[REGION_ID]

Now, consider Report 1B, again with the same attribute, Region, on the row
axis, but with a different simple metric defined as M1B=AvgDev(Revenue)
{~} on the column axis. This report shows how revenue data varies from its
mean for each region. The database does not support the function Average
Deviation; therefore, the computation is performed by the Analytical Engine.
The following SQL is generated:

Copyright © 2023 All Rights Reserved 62


Fu n ct io n s Refer en ce

l Report 1B (MicroStrategy Group-value function)

select a11.[CALL_CTR_ID] AS CALL_CTR_ID,


a11.[CUST_CITY_ID] AS CUST_CITY_ID,
a12.[REGION_ID] AS REGION_ID,
a13.[REGION_NAME] AS REGION_NAME,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CITY_CTR_SLS] a11,
[LU_CALL_CTR] a12,
[LU_REGION] a13
where a11.[CALL_CTR_ID] = a12.[CALL_CTR_ID] and
a12.[REGION_ID] = a13.[REGION_ID]
[An analytical SQL]

In Report 1B, Intelligence Server performs the following steps:

l It retrieves all fact data from the warehouse. [TOTAL_ DOLLAR_SALES] is


the column alias used for the fact (Revenue) in the temporary table during
SQL generation.

l It uses the result set (that is held in memory) to compute the metric,
namely AvgDev([TOTAL_ DOLLAR_SALES]){~} for each region.

l The notation [An analytical SQL] indicates that the computation is


taking place in the Analytical Engine.

l It displays the final result.

In the previous examples, the dimensionality of both metrics is defined as


{~}, which means that they both are calculated at the report level of Region,
since the attribute Region is on the reports.

The next example explains how Intelligence Server processes


dimensionality. When metric dimensionality is defined, the Analytical Engine
can insert records back into the temporary database structures after the
function calculation is performed so that dimensionality can be applied.

Copyright © 2023 All Rights Reserved 63


Fu n ct io n s Refer en ce

Exam ple 2: Sum (Revenue) {~, Country} vs. AvgDev(Revenue) {~, Country}

Now use the same report template as in Example 1, but add a dimensionality
to each metric for comparison. Use Sum(Revenue){~,Country} for
Report 2A and AvgDev(Revenue){~,Country} for Report 2B. Notice that
attribute Country is a parent of Region, and the relationship is one to many.
In Report 2A, the Sum function is supported by the database; in Report 2B,
the AvgDev function is supported by Intelligence Server. The SQL generated
for both reports is as follows:

Report 2A (SQL Group-Value Function) - Microsoft Access

create table ZZT1Y03009ZMD000 (


COUNTRY_ID BYTE,
WJXBFS1 DOUBLE)
insert into ZZT1Y03009ZMD000
select a12.[COUNTRY_ID] AS COUNTRY_ID,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CITY_CTR_SLS] a11,
[LU_CALL_CTR] a12
where a11.[CALL_CTR_ID] = a12.[CALL_CTR_ID]
group by a12.[COUNTRY_ID]
select a11.[REGION_ID] AS REGION_ID,
a11.[REGION_NAME] AS REGION_NAME,
pa1.[WJXBFS1] AS WJXBFS1
from [ZZT1Y03009ZMD000] pa1,
[LU_REGION] a11
where pa1.[COUNTRY_ID] = a11.[COUNTRY_ID]
drop table ZZT1Y03009ZMD000

The first pass of SQL creates a temporary table to hold the data. The second
pass computes the metric at the Country level, while the third pass joins with
attribute Region since the result of the aggregation has to be displayed for
each region. The final pass drops the temporary table.

Copyright © 2023 All Rights Reserved 64


Fu n ct io n s Refer en ce

Report 2B (MicroStrategy Group-Value Function)

select a11.[CUST_CITY_ID] AS CUST_CITY_ID,


a12.[COUNTRY_ID] AS COUNTRY_ID,
a11.[CALL_CTR_ID] AS CALL_CTR_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CITY_CTR_SLS] a11,
[LU_CALL_CTR] a12
where a11.[CALL_CTR_ID] = a12.[CALL_CTR_ID]
create table ZZMD00 (
COUNTRY_ID BYTE,
WJXBFS1 FLOAT)
[An analytical SQL]
insert into ZZMD00 values ([DummyInsertValue])
select a11.[REGION_ID] AS REGION_ID,
a11.[REGION_NAME] AS REGION_NAME,
pa1.[WJXBFS1] AS WJXBFS1
from [ZZMD00] pa1,
[LU_REGION] a11
where pa1.[COUNTRY_ID] = a11.[COUNTRY_ID]
drop table ZZMD00

In Report 2B, an Analytical SQL pass is necessary to compute AvgDev since


it is not a database supported group-value function. In the next pass, the
results of the calculation are inserted back into the temporary database
structures. The last SQL pass is the same as Report 2A, since it is used to
display the result for all regions.

Using Single-Value Functions


The key to understanding the computation of a single-value function is to
identify the way it is used. The next two subsections provide examples of the
two uses of single-value functions and how they are processed.

The first example shows a single-value function applied before a group-


value function. This is referred to as transforming a fact. The second
example shows a single-value function applied after the group-value
function. This is referred to as a compound metric.

Copyright © 2023 All Rights Reserved 65


Fu n ct io n s Refer en ce

Each example contains two reports, the first one showing the SQL syntax
when calculations are processed by the database and the second one when
calculations are processed by the Intelligence Server.

The use of transform in this context refers to retrieving a fact in a different


form. For example, you can obtain the absolute value for a fact or the
natural logarithm, but the fact is the same. This differs from a
transformation where the data retrieved is different when a transformation is
applied, for example, last year's revenue instead of this year's revenue.

Transforming a Fact Into Another Fact


In this case, the fact Revenue is transformed into another fact, namely the
natural logarithm values defined as Ln(Revenue) or the truncated revenue
values defined as Trunc(Revenue).

The following example describes this type of usage and displays the SQL
that is generated.

Consider the two metrics defined as follows:

l M3A = Sum(Ln(Revenue)){~+}

l M3B = Sum(Trunc(Revenue)){~+}

Put M3A with Region on the template. The database, in this case, SQL
Server 2000, supports the function Ln. The following SQL is generated:

Report 3A (SQL Single-Value Before Group-Value Function) - SQL Server


2000

Pass0 - Duration: 0:00:40.45


select a13.REGION_ID REGION_ID,
max(a14.REGION_NAME) REGION_NAME,
sum(LOG(a11.ORDER_AMT)) WJXBFS1
from ORDER_FACT a11
join LU_EMPLOYEE a12
on (a11.EMP_ID = a12.EMP_ID)

Copyright © 2023 All Rights Reserved 66


Fu n ct io n s Refer en ce

join LU_CALL_CTR a13


on (a12.CALL_CTR_ID = a13.CALL_CTR_ID)
join LU_REGION a14
on (a13.REGION_ID = a14.REGION_ID)
group by a13.REGION_ID

Based on the SQL, this is what happened:

1. The Ln function is applied to the fact Revenue, which is defined in the


warehouse by the column ORDER_AMT.

The Ln function uses the syntax LOG in SQL Server 2000.

2. Then, the Sum function is performed on the new fact, namely Ln


(Revenue).

Now, put M3B with Region on the template, the following SQL is generated:

Report 3B (MicroStrategy Single-Value Before Group-Value Function)

select a11.[CALL_CTR_ID] AS CALL_CTR_ID,


a11.[CUST_CITY_ID] AS CUST_CITY_ID,
a12.[REGION_ID] AS REGION_ID,
a13.[REGION_NAME] AS REGION_NAME,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CITY_CTR_SLS] a11,
[LU_CALL_CTR] a12,
[LU_REGION] a13
where a11.[CALL_CTR_ID] = a12.[CALL_CTR_ID] and
a12.[REGION_ID] = a13.[REGION_ID]
[An Analytical SQL]

In this case, as noted by the text [An Analytical SQL], the functions
Trunc and Sum are computed by the Intelligence Server. Intelligence Server
computes the new fact Trunc([Dollar Sales]) first and then uses the
Sum function to sum the new fact for each region.

Copyright © 2023 All Rights Reserved 67


Fu n ct io n s Refer en ce

Calculating a Compound Metric


Single-value functions can be used to create compound metrics.
Subtraction, addition, division, and multiplication operators (–, +, /, *) are
common examples of single-value functions. See the following examples:

l (Sum([Dollar Sales]){~}/Sum([Dollar Sales]) {~,Country})

l (Sum([Dollar Sales]){~} + Sum([Freight]) {~})

The examples below use a compound metric and a metric that transforms a
fact in the same report. The examples illustrate the SQL generated when the
function is supported by the database and the Intelligence Server,
respectively.

Consider the following metric definitions:

l M4A = Ln(Sum(Revenue){~})

l M4B = Trunc(Sum(Revenue){~})

Put metric M3A, from the previous example, and metric M4A together with
attribute Region on the template. The database, in this case SQL Server
2000, supports the Ln function. The following SQL is generated:

Report 4A (SQL Single-Value Before and After Group-Value Functions) -


SQL Server 2000

Pass0 - Duration: 0:00:02.58


select a13.REGION_ID REGION_ID,
max(a14.REGION_NAME) REGION_NAME,
sum(LOG(a11.ORDER_AMT)) WJXBFS1,
LOG(sum(a11.ORDER_AMT)) WJXBFS2
from ORDER_FACT a11
join LU_EMPLOYEE a12
on (a11.EMP_ID = a12.EMP_ID)
join LU_CALL_CTR a13
on (a12.CALL_CTR_ID = a13.CALL_CTR_ID)
join LU_REGION a14
on (a13.REGION_ID = a14.REGION_ID)

Copyright © 2023 All Rights Reserved 68


Fu n ct io n s Refer en ce

group by a13.REGION_ID

To process metric M3A, the single-value function Ln is calculated before the


group-value function Sum, and for metric M4A, Ln is calculated after Sum.

The Ln function uses the syntax LOG in SQL Server 2000.

Similarly, if you put metrics M3B and M4B together with attribute Region on
the template, and the database does not support the Trunc function, then the
following SQL is generated:

Pass0 - Duration: 0:00:12.67


select a11.ORDER_DATE DAY_DATE,
a11.EMP_ID EMP_ID,
a11.ORDER_ID ORDER_ID,
a13.REGION_ID REGION_ID,
a14.REGION_NAME REGION_NAME,
a11.ORDER_AMT WJXBFS1
from ORDER_FACT a11
join LU_EMPLOYEE a12
on (a11.EMP_ID = a12.EMP_ID)
join LU_CALL_CTR a13
on (a12.CALL_CTR_ID = a13.CALL_CTR_ID)
join LU_REGION a14
on (a13.REGION_ID = a14.REGION_ID)
Pass1 - Duration: 0:00:08.46
[An Analytical SQL]

The fact, Revenue, which is defined as column ORDER_AMT in the ORDER_


FACT table, is retrieved and used to compute both metrics.

Using OLAP Functions


You can better understand how Intelligence Server computes OLAP
functions by observing several examples based on the following properties:

l Window size

l BreakBy

Copyright © 2023 All Rights Reserved 69


Fu n ct io n s Refer en ce

l SortBy

l NULL handling

l Tie handling

There are two examples for each subsection, comparing the SQL syntax
when the database performs the OLAP function calculations with the one
when the Intelligence Server performs the computation.

Window Size in Moving Functions


For this example, define metric M1A as Sum(Revenue){~+}. Then create
an OLAP metric called OM1, that is defined as

MovingAvg <BreakBy = {Category}, SortBy = (Value)>([M1A],5).

OM1computes the moving average of M1A with a window size of 5. The


OLAP metric is computed after it is sorted by the value of M1A in ascending
order. Moreover, the computation restarts for every category.

Now, put the attributes Category and Item on the Row axis and the above
metrics on the Column axis. Run this report with an empty filter against a
database that does not support OLAP functions (in this case Microsoft
Access), the following SQL is generated:

Report 5A (MicroStrategy OLAP function - window size) - Microsoft Access

Pass0 - Duration: 0:00:00.60


select a13.[CATEGORY_ID] AS CATEGORY_ID,
max(a14.[CATEGORY_DESC]) AS CATEGORY_DESC,
a11.[ITEM_ID] AS ITEM_ID,
max(a12.[ITEM_NAME]) AS ITEM_NAME,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [ITEM_MNTH_SLS] a11,
[LU_ITEM] a12,
[LU_SUBCATEG] a13,
[LU_CATEGORY] a14
where a11.[ITEM_ID] = a12.[ITEM_ID] and

Copyright © 2023 All Rights Reserved 70


Fu n ct io n s Refer en ce

a12.[SUBCAT_ID] = a13.[SUBCAT_ID] and


a13.[CATEGORY_ID] = a14.[CATEGORY_ID]
group by a13.[CATEGORY_ID],
a11.[ITEM_ID]
Pass1 - Duration: 0:00:00.01
[An Analytical SQL]

Alternatively, if you execute the above report against a database that does
support OLAP computations (in this case Oracle 9i), then the following SQL
is generated:

Report 5B (DB OLAP Function - Window Size) - Oracle 9i

Pass0 - Duration: 0:00:10.15


select a13.CATEGORY_ID CATEGORY_ID,
a14.CATEGORY_DESC CATEGORY_DESC,
a11.ITEM_ID ITEM_ID,
a12.ITEM_NAME ITEM_NAME,
sum((a11.QTY_SOLD * (a11.UNIT_PRICE - a11.DISCOUNT)))
WJXBFS1,
avg(sum((a11.QTY_SOLD * (a11.UNIT_PRICE -
a11.DISCOUNT)))) over(partition by a13.CATEGORY_ID
order by sum((a11.QTY_SOLD * (a11.UNIT_PRICE -
a11.DISCOUNT))) asc rows 4 preceding) WJXBFS2
from ORDER_DETAIL a11,
LU_ITEM a12,
LU_SUBCATEG a13,
LU_CATEGORY a14
where a11.ITEM_ID = a12.ITEM_ID and
a12.SUBCAT_ID = a13.SUBCAT_ID and
a13.CATEGORY_ID = a14.CATEGORY_ID
group by a13.CATEGORY_ID,
a14.CATEGORY_DESC,
a11.ITEM_ID,
a12.ITEM_NAME

The following example shows how the Intelligence Server computes OLAP
functions when the database does not support OLAP functions. The

Copyright © 2023 All Rights Reserved 71


Fu n ct io n s Refer en ce

Intelligence Server retrieves all components: the input metric, BreakBy


parameter, and SortBy parameter. In the above examples, since the SortBy
parameter setting is by Value, it is sufficient to bring back just the input
metric ( WJXBFS1 ).

BreakBy in OLAP Functions


In the Intelligence Server, the BreakBy parameter is only available at the
attribute level. In other words, you can start over certain computations of
OLAP functions when a part of the metric belongs to a different attribute
element.

In the previous example (window size), there is an OLAP function with


Category in the BreakBy parameter. If the Analytical Engine computes the
OLAP function, Intelligence Server must select this attribute in the select
clause. If the database computes the OLAP function, then this attribute must
also be in the partition by clause.

Attributes in the BreakBy parameter of an OLAP metric are always applied,


meaning that they are always in the Select clause, and if the database
computes it, they are also in the Partition by clause. This is true
whether the attribute is on the template or not.

Run a report similar to the one for window size, deleting the attributes
Category and Item from the template and adding Subcategory. The results
for metric M1A are completely different from the previous report because if
Category and Item are not on the template, then the level of aggregation for
metric M1A is replaced by Subcategory, which is on the template. On the
other hand, OLAP metric OM1 must still restart the calculation (break by) for
each Category and therefore remains in the appropriate Select and
Partition by clauses. Notice that in both the SQLs below, the
Intelligence Server always selects Category even though Category is not on
the template.

For a database that does not support OLAP functions (in this case Microsoft
Access), the following SQL is generated:

Copyright © 2023 All Rights Reserved 72


Fu n ct io n s Refer en ce

Report 6A (MicroStrategy OLAP Function <BreakBy>) - Microsoft Access

Pass0 - Duration: 0:00:00.63


select a11.[SUBCAT_ID] AS SUBCAT_ID,
max(a12.[SUBCAT_DESC]) AS SUBCAT_DESC,
a12.[CATEGORY_ID] AS CATEGORY_ID,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CITY_SUBCATEG_SLS] a11,
[LU_SUBCATEG] a12
where a11.[SUBCAT_ID] = a12.[SUBCAT_ID]
group by a11.[SUBCAT_ID],
a12.[CATEGORY_ID]
Pass1 - Duration: 0:00:00.00
[An Analytical SQL]

If the database supports computation of OLAP functions (in this example


Oracle), then the following SQL is generated:

Report 6B (DB OLAP Function) - Oracle

Pass0 - Duration: 0:00:09.39


select a12.SUBCAT_ID SUBCAT_ID,
a13.SUBCAT_DESC SUBCAT_DESC,
a13.CATEGORY_ID CATEGORY_ID,
sum((a11.QTY_SOLD * (a11.UNIT_PRICE - a11.DISCOUNT)))
WJXBFS1,
avg(sum((a11.QTY_SOLD * (a11.UNIT_PRICE -
a11.DISCOUNT)))) over(partition by a13.CATEGORY_ID
order by sum((a11.QTY_SOLD * (a11.UNIT_PRICE -
a11.DISCOUNT))) asc rows 4 preceding) WJXBFS2
from ORDER_DETAIL a11,
LU_ITEM a12,
LU_SUBCATEG a13
where a11.ITEM_ID = a12.ITEM_ID and
a12.SUBCAT_ID = a13.SUBCAT_ID
group by a12.SUBCAT_ID,
a13.SUBCAT_DESC,
a13.CATEGORY_ID

Copyright © 2023 All Rights Reserved 73


Fu n ct io n s Refer en ce

Sorting in OLAP Functions


For OLAP functions, sorting is done before performing computations.
Basically, there are two choices for the SortBy parameter setting:

l Sort by Value in Subexpression: See Reports 5B (in Report 5B (DB


OLAP Function - Window Size) - Oracle 9i, page 71) and 6B (in Report 6B
(DB OLAP Function) - Oracle , page 73) for examples. Note that if the
database can perform computation of OLAP functions, then the definition
of the subexpression M1A displays in the order by clause.

For example, the above reports contain: "order by sum((a11.QTY_


SOLD * (a11.UNIT_PRICE - a11.DISCOUNT))) asc" to represent
the <SortBy = Value ascending> parameter setting.

l Sort by Objects: This type of sorting can use either attributes or metrics.
The following examples demonstrate the differences in processing when
an attribute or metric is used.

In this example, the OLAP metric is sorted by a normal attribute (either by ID


or Desc).

Create an OLAP metric defined as:

OM2 = RunningSum<BreakBy = {[Customer Region]}, SortBy =


([Customer City]@ID asc, Customer@Name dsc)>([M1A])

Then add the attributes Customer Region and Customer, and the metric OM2
to the template.

The metric OM2 is sorted by Customer City@ID in ascending order, then by


Customer@Name in descending order, though the attribute Customer City is
not on the template. Assume that attribute Customer is a child of the
attribute Customer City, and Customer City is a child of Customer Region.

For a database that does not support OLAP functions (in this case Microsoft
Access), the following SQL is generated:

Copyright © 2023 All Rights Reserved 74


Fu n ct io n s Refer en ce

Report 7A (MicroStrategy OLAP Function <SortBy>) - Microsoft Access

select a14.[CUST_REGION_ID] AS CUST_REGION_ID,


a15.[CUST_REGION_NAME] AS CUST_REGION_NAME,
a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a12.[CUST_LAST_NAME] AS CUST_LAST_NAME,
a12.[CUST_FIRST_NAME] AS CUST_FIRST_NAME,
a12.[CUST_CITY_ID] AS CUST_CITY_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CUSTOMER_SLS] a11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[LU_CUST_REGION] a15
where a11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID] and
a14.[CUST_REGION_ID] = a15.[CUST_REGION_ID]
[An Analytical SQL]

If the database supports computation of OLAP functions (in this example


Oracle 9i), the following SQL is generated:

Report 7B (DB OLAP Function <SortBy>) - Oracle

Pass0 - Duration: 0:00:15.00


select a15.CUST_REGION_ID CUST_REGION_ID,
a16.CUST_REGION_NAME CUST_REGION_NAME,
a12.CUSTOMER_ID CUSTOMER_ID,
a13.CUST_LAST_NAME CUST_LAST_NAME,
a13.CUST_FIRST_NAME CUST_FIRST_NAME,
a13.CUST_CITY_ID CUST_CITY_ID,
sum(sum(a11.ORDER_AMT)) over(partition by
a15.CUST_REGION_ID order by a13.CUST_CITY_ID asc,
a13.CUST_LAST_NAME desc, a13.CUST_FIRST_NAME desc rows
unbounded preceding) WJXBFS1
from ORDER_FACT a11,
LU_ORDER a12,
LU_CUSTOMER a13,

Copyright © 2023 All Rights Reserved 75


Fu n ct io n s Refer en ce

LU_CUST_CITY a14,
LU_CUST_STATE a15,
LU_CUST_REGION a16
where a11.ORDER_ID = a12.ORDER_ID and
a12.CUSTOMER_ID = a13.CUSTOMER_ID and
a13.CUST_CITY_ID = a14.CUST_CITY_ID and
a14.CUST_STATE_ID = a15.CUST_STATE_ID and
a15.CUST_REGION_ID = a16.CUST_REGION_ID
group by a15.CUST_REGION_ID,
a16.CUST_REGION_NAME,
a12.CUSTOMER_ID,
a13.CUST_LAST_NAME,
a13.CUST_FIRST_NAME,
a13.CUST_CITY_ID

In both SQLs, the Intelligence Server selects a13.CUST_CITY_ID, even


though attribute Customer City is not on the report. In Report 7B, this
attribute is also in the group by clause. Sort by attribute Customer City@ID
is done because of attribute Customer that is a child of Customer City.

In Report 7B, the SQL has to issue group by CUST_LAST_NAME and


CUST_FIRST_NAME due to the sort by Customer@Name. For optimization
purposes, the Intelligence Server only groups by the ID column.

There is a VLDB setting that allows you to group by non-ID columns. This
VLDB setting can be set for any report that uses an OLAP metric with a sort
by attribute description.

In this example, an OLAP metric is sorted by an attribute and a metric.

Create an OLAP metric defined as:

OM3 = RunningSum<BreakBy = {[Customer Region]}, SortBy =


(Customer@[Last Name] desc, [M1A] asc)>([M1A])

Then add attributes Customer Region and Customer, and metric OM3 to the
template. The OLAP metric OM3 is sorted by Customer Last Name and then
by the metric [M1A].

Copyright © 2023 All Rights Reserved 76


Fu n ct io n s Refer en ce

For databases that do not support OLAP functions (in this case Microsoft
Access), the following SQL is generated:

Report 8A (MicroStrategy OLAP Function <SortBy>) - Microsoft Access

Pass0 - Duration: 0:00:00.47


select a14.[CUST_REGION_ID] AS CUST_REGION_ID,
a15.[CUST_REGION_NAME] AS CUST_REGION_NAME,
a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a12.[CUST_LAST_NAME] AS CUST_LAST_NAME,
a12.[CUST_FIRST_NAME] AS CUST_FIRST_NAME,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CUSTOMER_SLS] a11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[LU_CUST_REGION] a15
where a11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID] and
a14.[CUST_REGION_ID] = a15.[CUST_REGION_ID] and
a14.[CUST_REGION_ID] in (3, 7)
Pass1 - Duration: 0:00:00.06
[An Analytical SQL]

If the database supports computation of OLAP functions (in this example


Oracle), the following SQL is generated:

Report 8B (DB OLAP Function <SortBy>) - Oracle

select a15.CUST_REGION_ID CUST_REGION_ID,


a16.CUST_REGION_NAME CUST_REGION_NAME,
a12.CUSTOMER_ID CUSTOMER_ID,
a13.CUST_LAST_NAME CUST_LAST_NAME,
a13.CUST_FIRST_NAME CUST_FIRST_NAME,
sum(a11.ORDER_AMT) WJXBFS1,
sum(sum(a11.ORDER_AMT)) over(partition by
a15.CUST_REGION_ID order by a13.CUST_LAST_NAME desc,

Copyright © 2023 All Rights Reserved 77


Fu n ct io n s Refer en ce

sum(a11.ORDER_AMT) desc rows unbounded preceding)


WJXBFS2
from ORDER_FACT a11,
LU_ORDER a12,
LU_CUSTOMER a13,
LU_CUST_CITY a14,
LU_CUST_STATE a15,
LU_CUST_REGION a16
where a11.ORDER_ID = a12.ORDER_ID and
a12.CUSTOMER_ID = a13.CUSTOMER_ID and
a13.CUST_CITY_ID = a14.CUST_CITY_ID and
a14.CUST_STATE_ID = a15.CUST_STATE_ID and
a15.CUST_REGION_ID = a16.CUST_REGION_ID
and a15.CUST_REGION_ID in (7, 3)
group by a15.CUST_REGION_ID,
a16.CUST_REGION_NAME,
a12.CUSTOMER_ID,
a13.CUST_LAST_NAME,
a13.CUST_FIRST_NAME

NULL Handling in OLAP Functions


When sorted by Intelligence Server, NULL is placed at the end of a list.
Databases also put NULL at the end, as required by the ANSI standard.

For RunningCount or MovingCount functions, NULL is always ignored. For


other computations, such as RunningSum or MovingAvg, NULL is treated as
zero for the sum of values across the function parameters. This behavior is
consistent for Intelligence Server and ANSI-compliant database OLAP
functions.

Tie Handling in OLAP Functions


Tie Handling is related to the SortBy parameter when you sort a tie in a
metric. Intelligence Server uses a Merge-Sort algorithm, which always
preserves the original order retrieved from the database (via ODBC) to the
Intelligence Server.

Copyright © 2023 All Rights Reserved 78


Fu n ct io n s Refer en ce

It is not known whether databases use the same sort algorithm; therefore,
the Intelligence Server and database computation of OLAP functions can
produce different results whenever there is a tie on the data.

Using Custom Plug-In Functions


Function Plug-Ins in the MicroStrategy Engine allow users to define their
own collection of functions, and then let the Engine use them for further
analysis. The plug-in functions, usually called user-defined functions,
behave as if they are an integrated part of MicroStrategy and are
indistinguishable from all other MicroStrategy functions or operators, such
as Sum, Average, Min, Max, Count, -, +, /, or *. The Intelligence Server
performs standard computations such as Sum, Average, +, /, and so on that
are usually calculated by the database.

MicroStrategy is equipped with approximately 250 functions and operators,


including predefined plug-in functions created by MicroStrategy. They are
intended to provide three full-featured libraries of functions that are most
commonly used by customers, which includes financial functions, math
functions, and statistical functions. Examples include Accrint, IRR, NPV,
Abs, Ln, Log, AvgDev, HomoscedasticTTest, Confidence, and so on. These
functions are located at ...Schema Objects/Functions and
Operators/Plug-In Packages.

For detailed information on individual functions, see Chapter 4, Plug-In


Package Functions and the Function Plug-in Wizard online help.

Creating User-Defined Plug-In Functions


Using the MicroStrategy Function Plug-In Wizard, you can define custom
functions relevant to your business case scenarios. You can create
individual functions or even entire function packages, such as the financial,
mathematical, and statistical packages, provided by MicroStrategy. Guided
by the wizard, you start by creating a Microsoft Visual C++ project with
placeholders where you can add custom analytic code. After the new plug-in
function is created, you need to launch MicroStrategy Developer to import it

Copyright © 2023 All Rights Reserved 79


Fu n ct io n s Refer en ce

so it can be used for all the reports. As mentioned previously, once a


function is imported, it will be used in the same way as any other standard
MicroStrategy function.

For instructions on creating a plug-in function, see the Function Plug-in


Wizard online help.

The main stages of the creation process are described as follows:

l Designing: determines how to implement the analytical procedures into a


computer algorithm.

l Creating: creates the Microsoft Visual C++ project, which is used to build
a library containing your algorithms.

l Implementing: creates the code that embodies the algorithms and


compiling this code into a library that is used by MicroStrategy.

l Importing: adds the library to a MicroStrategy project so that its


algorithms are available for use in the project.

l Executing: creates new metrics that use the algorithms and using those
metrics in a MicroStrategy report.

You can create the following types of functions:

l Single-value functions

l Group-value functions

l OLAP functions

The datatypes of input arguments can be:

l Numeric

l Date

l String

A plug-in function can contain more than one parameter. Supported


datatypes for parameters include:

Copyright © 2023 All Rights Reserved 80


Fu n ct io n s Refer en ce

l Byte

l Short

l Long

l Float

l Double

l String (BSTR)

l Bool

l Date

The following two examples illustrate how plug-in functions could be


defined:

l FORECAST<n>(numeric_vector1) = numeric1

l Aggregate function with a numeric vector as an input argument and a numeric scalar
as an output argument.

l One parameter, n, which is a long integer.

l Given a series of values, and given that those values are each separated by one time
interval, this function predicts what the value will be after n additional time intervals.

For example, you include the unit cost of an item in order to predict how
much the unit cost will be two years later.

FORECAST<2>(UnitCost)

In this example, UnitCost includes a four year history of data, providing


the following yearly values to the FORECAST function.

FORECAST<2>(100,120,140,160)

This results in a value of 200, which is the predicted unit cost two years
from the time of the most recently recorded cost data.

Copyright © 2023 All Rights Reserved 81


Fu n ct io n s Refer en ce

l CUSTOMNUMBERFORMAT(numeric1) = string1

l Simple function with numeric scalar as input argument and string scalar as output
argument.

l No parameters.

l Transforms a number into a string representation of that number not supported by


any of MicroStrategy's out-of-the-box metric format strings.

Example: CUSTOMNUMBERFORMAT(123456789) = '1 2345.6789'

To Install the Function Plug-In Wizard

1. From ...\MicroStrategy\Workstation, click FPWizard.exe.

2. Follow the prompts to install.

To Activate the Function Plug-In Wizard

1. From the Start button, select Programs > Microsoft Visual Studio >
Microsoft Visual C++.

2. From the File menu, select New.

3. On the Projects tab, select MicroStrategy Function Plug-in Wizard.

4. Enter a name in the Project Name text box.

Do not use spaces in the project name. Because the project name will
become the name of the library, use something short and descriptive.
For illustration purposes, the project name myFP is used throughout
the online help.

5. Change the location of the project, if needed. Then click OK. The
Function Plug-in Wizard - Step 1 of 2 window is displayed.

Copyright © 2023 All Rights Reserved 82


Fu n ct io n s Refer en ce

To Access the Function Plug-in Wizard Online Help from the


MicroStrategy Online Help

1. In the master MicroStrategy online help, search for custom functions,


or open the Creating and Modifying Additional Report Objects
folder, expand the Metrics folder, and then expand the Using custom
functions folder.

2. Launch the Using custom functions topic. This topic contains a link to
the Function Plug-in Wizard online help.

3. Click the Function Plug-in Wizard on-line help link. The Function
Plug-in Wizard online help opens in a new help window.

Additional Examples of Functions in Expressions


Hypothesis Testing Example
The reports and report objects in this example can be found in the following
folder: MicroStrategy Tutorial\Public Objects\Reports\
MicroStrategy Platform Capabilities\Advanced Analytics\
Statistics and Forecasting\Hypothesis Testing

Which Call Centers had a Statistically Significant


Increase in the Average Daily Sales in Recent Years?
To answer this question, you must first find the average of daily sales for
recent years for each call center. You accomplish this using the Average
Daily Sales metric, defined as:

Average Daily Sales = Avg(Sum(Revenue) {~+, Day+} ) {~+}

This is a simple metric that contains the nested group-value functions Sum
and Avg.

Copyright © 2023 All Rights Reserved 83


Fu n ct io n s Refer en ce

Next, create a report that uses this metric, placing the Call Center attribute
on the row axis and the Year attribute on the column axis. A report with this
definition is shown below.

In this report it looks like all call centers had a significant increase in the
average daily sales in each successive year. However, an average value by
itself does not represent the complete picture.

To get more information, you can check the standard deviation of daily sales
between each successive year for each call center. You can accomplish this
by adding Standard Deviation in Daily Sales to the report. The metric is
defined as:

StDev Daily Sales = Stdev(Sum(Revenue) {~+, Day+} ) {~+}

In statistics, standard deviation is a value which shows how widely a set of


values differs from the mean.

The resulting report provides the average and the standard deviation of daily
sales for all years, for each call center.

Copyright © 2023 All Rights Reserved 84


Fu n ct io n s Refer en ce

This report shows that all call centers have greater average daily sales in
each successive year. Additionally, the standard deviation of daily sales is
higher for each successive year, with a number of exceptions. A couple of
these exceptions include Atlanta between 2009 and 2010, as well as San
Francisco between 2008 and 2009. The higher standard deviation values
mean that there is more volatility in these results. Therefore, the higher
average daily sales in each successive year are not necessarily a
progressive increase over previous years; they may have been caused by
random fluctuations.

Based on this observation, you next need to find out which call centers have
a statistically significant difference in their average daily sales between
these successive years. You can get the result by testing the hypothesis that
the average daily sales are the same, against the hypothesis that the
average daily sales are significantly different. This must be tested for each
call center.

The hypothesis testing is accomplished by computing the p-value. In


statistics, p-value is the probability of making a decision to reject a fact,
given that the fact is correct. In the context of this example, it is the

Copyright © 2023 All Rights Reserved 85


Fu n ct io n s Refer en ce

probability of making a mistake by concluding that the average daily sales in


2008 is significantly different from 2009, given that actually they are about
the same. In general, you want to restrict this type of error so that it is
smaller than a certain tolerance level. This tolerance level is usually set to
between 2.5% to 10.0%.

If you assume that the standard deviations of daily sales for all years are the
same, then you can use a function called HomoscedasticTTest to compute
the p-value. If you assume that the daily standard deviations are different,
then you must use the function HeteroscedasticTTest. The following
examples consider both of these assumptions and compute the p-value
using HomoscedasticTTest and HeteroscedasticTTest.

This report uses simple metrics based on other metrics, because to


calculate the p-value, you need to compute the daily sales for each call
center for each day. You also need to group the fact Revenue at the levels of
Day and Call Center for all years. The fact table DAY_CTR_SLS is available
at the levels of Employee, Order, and Day.

Call Center is related to the fact table via Employee.

You need a table with a structure similar to the following:

Daily Sales Daily Sales


Call Center Day
(last year) (current year)

1 123456 123456

Northwest ... 123456 123456

N 123456 123456

1 123456 123456

Southeast ... 123456 123456

N 123456 123456

Copyright © 2023 All Rights Reserved 86


Fu n ct io n s Refer en ce

You need to create a temporary table with this structure using metrics.
These metrics are then used in simple metrics to calculate the p-value.

Follow the steps below to build the necessary metrics for the Hypothesis
Testing report.

1. Build a metric to create the column for [Daily Sales (current year)] in
the temporary table. This metric is defined as:

Daily Sales (current year)= Sum(Revenue) {~+, Day+} <


[Current year in sample DB]; @2; ->

The default level notation {~+} is placed on the metric since the default
is to group by an attribute on the report. In this example, that report
attribute is Call Center. The metric condition Current year in
sample DB is also applied to calculate the data for the current year
available in the MicroStrategy Tutorial data.

2. Build a metric to create the column for [Daily Sales (last year)] in the
temporary table. This metric is defined as:

Daily Sales (last year) = Sum(Revenue) {~+, Day+} <


[Last year in sample DB]; @2; -> | [Last Year's] |

This metric uses a metric condition and a transformation.

l The metric condition Last year in sample DB is applied to


calculate the data for the previous year available in the MicroStrategy
Tutorial data.

l The transformation Last Year's is necessary because attribute


Day is a child of attribute Year. To show Daily Sales in Day 1, 2, …, N
of last year together with Daily Sales in Day 1, 2, …, N of the current
year, you must use the transformation to supply this data.

3. Build the simple metrics to compute the p-value for each call center by
using the metrics above. The simple metrics are defined as follows:

Copyright © 2023 All Rights Reserved 87


Fu n ct io n s Refer en ce

HeteroscedasticTTest([Daily Sales (last year)], [Daily


Sales (current year)]) {~+}

HeteroscedasticTTest([Daily Sales (last year)], [Daily


Sales (current year)]) {~+}

Create a report with the two metrics shown above (for p-value) and the
attribute Call Center. The Hypothesis Testing report is shown below.

The resulting report, Hypothesis Testing, is shown above. All call


centers, except for Atlanta, Salt Lake City, Seattle, and Fargo, have a
p-value of less that 5%. This indicates that the probability of making an
error in concluding that the sales have significantly increased is low for
all but these four call centers.

Additionally, even Salt Lake City and Fargo are at 20% or lower. This is
strong evidence that average daily sales for the majority of the call
centers can be attributed to a steady increase, rather than random
fluctuations.

Copyright © 2023 All Rights Reserved 88


Fu n ct io n s Refer en ce

The SQL generated for the report Hypothesis Testing is displayed


below, along with a summary of the actions taken at the end of the SQL
statement:

Pass0 - Execution Duration:0:00:00.06


create table ZZTH0FDXLS4MD000 (
DAY_DATE TIMESTAMP,
CALL_CTR_ID SHORT,
WJXBFS1 DOUBLE)
Pass1 - Execution Duration:0:00:00.34
insert into ZZTH0FDXLS4MD000
select a12.[DAY_DATE] AS DAY_DATE,
a11.[CALL_CTR_ID] AS CALL_CTR_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [DAY_CTR_SLS] a11,
[LU_DAY] a12
where a11.[DAY_DATE] = a12.[LY_DAY_DATE]
and a12.[YEAR_ID] in (2010)
Pass2 - Execution Duration: 0:00:00.00
create table ZZTU1RY0YSKMD001 (
DAY_DATE TIMESTAMP,
CALL_CTR_ID SHORT,
WJXBFS1 DOUBLE)
Pass3 - Execution Duration: 0:00:00.03
insert into ZZTU1RY0YSKMD001
select a11.[DAY_DATE] AS DAY_DATE,
a11.[CALL_CTR_ID] AS CALL_CTR_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [DAY_CTR_SLS] a11,
[LU_DAY] a12
where a11.[DAY_DATE] = a12.[DAY_DATE]
and a12.[YEAR_ID] in (2010)
Pass4 - Execution Duration: 0:00:00.07
select pa11.[CALL_CTR_ID] AS CALL_CTR_ID,
a13.[CENTER_NAME] AS CENTER_NAME,
pa11.[DAY_DATE] AS DAY_DATE,
pa11.[WJXBFS1] AS WJXBFS1,
pa12.[WJXBFS1] AS WJXBFS2

Copyright © 2023 All Rights Reserved 89


Fu n ct io n s Refer en ce

from [ZZTH0FDXLS4MD000] pa11,


[ZZTU1RY0YSKMD001] pa12,
[LU_CALL_CTR] a13
where pa11.[CALL_CTR_ID] = pa12.[CALL_CTR_ID] and
pa11.[DAY_DATE] = pa12.[DAY_DATE] and
pa11.[CALL_CTR_ID] = a13.[CALL_CTR_ID]
Pass5 - Execution Duration: 0:00:00.00
[Analytical SQL calculated by the Analytical Engine:
select CALL_CTR_ID,
CENTER_NAME,
HomoscedasticTTest(WJXBFS1, WJXBFS2),
HeteroscedasticTTest(WJXBFS1, WJXBFS2)
from [previous pass]
]
Pass6 - Execution Duration: 0:00:00.00
[Populate Report Data]
Pass7 - Execution Duration: 0:00:00.06
drop table ZZTH0FDXLS4MD000
Pass8 - Execution Duration: 0:00:00.01
drop table ZZTU1RY0YSKMD001

l Pass0 and Pass1 are issued by Intelligence Server to compute the metric
Daily Sales (last year). The Intelligence Server prepares the temporary
table with Call Center and Day as its key. Then, it retrieves last year's
sales using the transformation Last Year's.

l Pass2 and Pass3 are issued to compute the metric Daily Sales (current
year). Attributes Call Center and Day are used as keys to the temporary
table. This pass is similar to Pass0 and Pass1 with the key difference
being that the metric does not have a transformation.

l In Pass4 and Pass5, the Intelligence Server computes the p-value for each
call center, using the HeteroscedasticTTest and the HomoscedasticTTest
functions.

l The remaining passes perform final report preparation and drop the
temporary tables.

Copyright © 2023 All Rights Reserved 90


Fu n ct io n s Refer en ce

Confidence Level Example


The reports and report components in this example can be found in the
following folder:

MicroStrategy Tutorial\Public Objects\Reports\


MicroStrategy Platform Capabilities\Advanced Analytics\
Statistics and Forecasting\Confidence Level

Confidence level is used to determine valuable customers in two slightly


different ways:

l Who are my Valuable Customers? (Example 1), page 91: Determines


valuable customers as those whose average spending is above an upper
bound of sales orders.

l Who are my Valuable Customers? (Example 2), page 97: Determines


valuable customers as those whose average spending is above an upper
bound of sales orders. Additionally, valuable customers are compared for
each Customer Region, rather than comparing customers in all regions.

Who are my Valuable Customers? (Example 1)


The basic goal is to define a cut-off value that represents the minimum
requirement to be classified as a valuable customer. To identify the valuable
customers in your customer base, you must determine the parameters that
help differentiate those customers from the others. In this example, valuable
customers are those whose average spending is above an upper bound of
sales orders.

The ORDER_FACT table contains all orders received. Assume that the sales
order amount is normally distributed with a certain mean and standard
deviation. Based on the assumption of normal distribution and a confidence
level of 99%, you can define valuable customers as those who have a
spending average above an upper bound of sales orders.

To determine the valuable customers based on this criteria, you need to


know several values. Use the following metrics to obtain these values.

Copyright © 2023 All Rights Reserved 91


Fu n ct io n s Refer en ce

1. You must know the average sales order from all orders in the ORDER_
FACT table. This is the arithmetic mean of the normal distribution. You
can get this value using the Avg function. The metric to compute the
average of sales orders from the ORDER_FACT table can be defined as:

M01 = Avg(Revenue) {![Call Center]+, !Year+,


!Employee+, !Order+, !Day+}

Since Day, Employee, and Order are the highest attributes that are
parents of the keys in the ORDER_FACT table, include them as the level
of aggregation to make sure that the ORDER_FACT table is used. Also,
the average must be calculated over all sales order amounts, so you
must set the group-by on the level attributes to none. This ensures that
the metric does not group by any of these attributes.

2. You must know the standard deviation of sales orders from all orders.
This number is the standard deviation of the normal distribution. You
can get this value using the StDevP function (see StDevP (Standard
Deviation of a Population), page 140).

The metric to compute the population standard deviation of sales


orders from the ORDER_FACT table is defined as follows:

M02 = StdevP(Revenue) {![Call Center]+, !Year+,


!Employee+, !Order+, !Day+}

3. You must know the number of rows in the ORDER_FACT table. You need
this value to calculate the cut-off value. You can retrieve this value by
using the Count function, in particular, Count from the ORDER_FACT
table. The metric to count the data in the ORDER_FACT table is defined
as follows:
M03 = Count(Revenue) {![Call Center]+, !Year+,
!Employee+, !Order+, !Day+}

4. Under the assumption of normal distribution with the parameters given


above, you must determine the cut-off value that represents the top 5%

Copyright © 2023 All Rights Reserved 92


Fu n ct io n s Refer en ce

of sales order amounts. To do this, you can use the Confidence plug-in
function. The metric to compute the cut-off number is defined as
follows, using some of the metrics defined above:
M04 = Confidence(0.01, [M02], [M03])

The number 0.01 comes from a normal distribution with 99%


confidence level.

5. The metric that calculates the upper bound uses some of the metrics
defined above, and is defined as follows:
M05 = ([M01] + [M04])

6. You must calculate the average sales for each customer to get a list of
valuable customers based on the criteria. The metric is defined as
follows:
Average Sales = Avg(Revenue) {~+}
You do not need to include the level of aggregation
for Average Sales since the default {~+} notation is
replaced by the attribute Customer.

7. You must also apply a metric qualification in a filter to restrict the rows
returned to those that meet the definition of valuable customers. The
filter is defined as follows:

F01 = Set of Customers where (Average Sales Greater


than [M05]

To generate a report listing valuable customers, create a report with the


attribute Customer on the row axis and the attribute Customer Region
on the page-by axis. Apply filter F01 to the report to produce a list of
valuable customers for each attribute element in Customer Region. The
Valuable Customers 01 report is shown below:

Copyright © 2023 All Rights Reserved 93


Fu n ct io n s Refer en ce

The SQL generated for the report Valuable Customers 01 is as follows:

Pass0 - Execution Duration: 0:00:00.07


create table ZZTLZV82TJ0MD000 (
CUSTOMER_ID LONG,
WJXBFS1 DOUBLE)
Pass1 - Execution Duration: 0:00:00.20
insert into ZZTLZV82TJ0MD000
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
avg(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CUSTOMER_SLS] a11
group by a11.[CUSTOMER_ID]
Pass2 - Execution Duration: 0:00:00.04
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[ORDER_ID] AS ORDER_ID,
a11.[ITEM_ID] AS ITEM_ID,
a11.[EMP_ID] AS EMP_ID,

Copyright © 2023 All Rights Reserved 94


Fu n ct io n s Refer en ce

a11.[ORDER_DATE] AS DAY_DATE,
a11.[CUSTOMER_ID] AS CUSTOMER_ID0,
(a11.[QTY_SOLD] * (a11.[UNIT_PRICE] - a11.[DISCOUNT]))
AS WJXBFS1
from [ORDER_DETAIL] a11
Pass3 - Execution Duration: 0:00:00.10
create table ZZTW4A12VECMD001 (
CUSTOMER_ID LONG,
WJXBFS1 DOUBLE)
Pass4 - Execution Duration: 0:00:00.00
[Analytical SQL calculated by the Analytical Engine:
select CUSTOMER_ID0,
(ISNULL(avg(WJXBFS1), 0) + Confidence(0.01,
StdevP(WJXBFS1), count(WJXBFS1)))
from [previous pass]
]
Pass5 - Execution Duration: 0:00:00.00
insert into ZZTW4A12VECMD001 values (1, 33.4351602545)
Pass6 - Execution Duration: 0:00:00.00
create table ZZTPDKUSLWSMQ002 (
CUSTOMER_ID LONG)
Pass7 - Execution Duration: 0:00:00.10
insert into ZZTPDKUSLWSMQ002
select pa11.[CUSTOMER_ID] AS CUSTOMER_ID
from [ZZTLZV82TJ0MD000] pa11,
[ZZTW4A12VECMD001] pa12
where pa11.[CUSTOMER_ID] = pa12.[CUSTOMER_ID]
and (pa11.[WJXBFS1] &gt; pa12.[WJXBFS1])
Pass8 - Execution Duration: 0:00:01.53
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
max(a13.[CUST_LAST_NAME]) AS CUST_LAST_NAME,
max(a13.[CUST_FIRST_NAME]) AS CUST_FIRST_NAME,
a15.[CUST_REGION_ID] AS CUST_REGION_ID,
max(a16.[CUST_REGION_NAME]) AS CUST_REGION_NAME0,
avg(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CUSTOMER_SLS] a11,
[ZZTPDKUSLWSMQ002] pa12,

Copyright © 2023 All Rights Reserved 95


Fu n ct io n s Refer en ce

[LU_CUSTOMER] a13,
[LU_CUST_CITY] a14,
[LU_CUST_STATE] a15,
[LU_CUST_REGION] a16
where a11.[CUSTOMER_ID] = pa12.[CUSTOMER_ID] and
a11.[CUSTOMER_ID] = a13.[CUSTOMER_ID] and
a13.[CUST_CITY_ID] = a14.[CUST_CITY_ID] and
a14.[CUST_STATE_ID] = a15.[CUST_STATE_ID] and
a15.[CUST_REGION_ID] = a16.[CUST_REGION_ID]
group by a11.[CUSTOMER_ID],
a15.[CUST_REGION_ID]
Pass9 - Execution Duration: 0:00:00.00
[Populate Report Data]
Pass10 - Execution Duration: 0:00:00.06
drop table ZZTLZV82TJ0MD000
Pass11 - Execution Duration: 0:00:00.00
drop table ZZTW4A12VECMD001
Pass12 - Execution Duration: 0:00:00.00
drop table ZZTPDKUSLWSMQ002

l Pass0 and Pass1 compute the average sales per customer (Average Sales
metric) and put the results in a temporary table.

l Pass2 retrieves ORDER_DETAIL data, puts the data into memory, and uses
the data to compute M01, M02, and M03.

l Pass3 creates a temporary table used to store the results of the


calculations.

l Pass4 calculates M02 using the Intelligence Server because the group-
value function StDevP is not supported by the Access database. The
values of M01, M02, and M03 are used to compute M05.

l Pass5 inserts the results of the calculations into the temporary table.

l Pass6 and Pass7 use the earlier two temporary tables to qualify on
valuable customers based on the definition.

l Pass8 displays the report with attributes Customer and Customer Region.

Copyright © 2023 All Rights Reserved 96


Fu n ct io n s Refer en ce

l The remaining passes perform additional report preparation and drop the
temporary tables.

Who are my Valuable Customers? (Example 2)


This example generates a list of valuable customers based on a different
definition from the previous example.

Assume a normal distribution of sales orders is still valid, but the cut-off
value is for each Customer Region. This means you must compare the
average spending of each customer against the average spending of the
Customer Region to which the customer belongs. To allow for more
variation, take the average value from the current year data, but use sample
standard deviations for all available years. Use a confidence level of 95%.

Valuable customers are defined as those customers who have total spending
above the cut-off value. The cut-off value is calculated using the filters and
metrics defined below:

1. The filter used to limit the calculation of average sales orders to only
the data for the current year is defined as follows:

Current year in sample DB = Year In list (2010)

2. The metric used to calculate the average sales order is defined as


follows:

M07= Avg(Revenue) {[Customer Region]+, !Year+,


!Employee+, !Order+, !Day+} <[Current year in sample
DB]; @2; ->

3. The metric used to calculate the standard deviation of sales orders is


defined as follows:

M08 = Stdev(Revenue) {[Customer Region]+, ![Call


Center]+, !Year+, !Employee+, !Order+, !Day+}

Copyright © 2023 All Rights Reserved 97


Fu n ct io n s Refer en ce

Notice that the function Stdev (standard deviation of a sample) is used


in this metric because the amount of data is limited to each Customer
Region. This means the data can be considered as more of a sample
than a full population.

4. The metric used to determine the cut-off value is defined as follows,


using the preceding metrics:
M09 = ([M07] + (1.96 * [M08]))

The number 1.96 comes from a normal distribution with 95%


confidence level. In practice, this number is often rounded to 2 instead
of 1.96.

5. The metric used to determine each customer's spending so that it can


be compared to the cut-off value is defined as follows:
M10 = Sum(Revenue){~+}

6. The metric qualification (filter) needed to restrict the report to a list of


valuable customers based on Definition 2 is defined as follows:

F03 = Set of Customer where (M10 Greater than [M09])

7. To view the last order sales from all valuable customers, use the metric
defined as follows:
Last Order Sales = Sum(Revenue) {~+, >|Day+}

You must compute order sales for each customer at the Day level from
the ORDER_FACT table, but must take it from the last Day on that fact
table. The {~+} is replaced by any attribute on the report. In this
example, it is the Customer attribute.

Build a report putting the attribute Customer on the row axis, the
attribute Customer Region on the page-by axis, and the Last Order
Sales metric on the column axis, then applying the filter F03. The
Valuable Customers 02 report is shown below.

Copyright © 2023 All Rights Reserved 98


Fu n ct io n s Refer en ce

The SQL generated by the Valuable Customers 02 report is as follows:

Pass0 - Execution Duration: 0:00:00.00


create table ZZT3WSP7T8BMD000 (
CUSTOMER_ID LONG,
WJXBFS1 DOUBLE)
Pass1 - Execution Duration: 0:00:00.06
insert into ZZT3WSP7T8BMD000
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS1
from [CUSTOMER_SLS] a11
group by a11.[CUSTOMER_ID]
Pass2 - Execution Duration: 0:00:00.00
create table ZZT36UF785VMD001 (
CUST_REGION_ID SHORT,

Copyright © 2023 All Rights Reserved 99


Fu n ct io n s Refer en ce

WJXBFS1 DOUBLE)
Pass3 - Execution Duration: 0:00:02.18
insert into ZZT36UF785VMD001
select a14.[CUST_REGION_ID] AS CUST_REGION_ID,
avg((a11.[QTY_SOLD] * (a11.[UNIT_PRICE] -
a11.[DISCOUNT]))) AS WJXBFS1
from [ORDER_DETAIL] a11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[LU_DAY] a15
where a11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID] and
a11.[ORDER_DATE] = a15.[DAY_DATE]
and a15.[YEAR_ID] in (2010)
group by a14.[CUST_REGION_ID]
Pass4 - Execution Duration: 0:00:00.03
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[ORDER_ID] AS ORDER_ID,
a11.[ITEM_ID] AS ITEM_ID,
a11.[EMP_ID] AS EMP_ID,
a11.[ORDER_DATE] AS DAY_DATE,
a14.[CUST_REGION_ID] AS CUST_REGION_ID,
(a11.[QTY_SOLD] * (a11.[UNIT_PRICE] - a11.[DISCOUNT]))
AS WJXBFS1
from [ORDER_DETAIL] a11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14
where a11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID]
Pass5 - Execution Duration: 0:00:00.00
create table ZZTS6MZ3N2BMD002 (
CUST_REGION_ID SHORT,
WJXBFS1 DOUBLE)

Copyright © 2023 All Rights Reserved 100


Fu n ct io n s Refer en ce

Pass6 - Execution Duration: 0:00:00.00


[Analytical SQL calculated by the Analytical Engine:
select CUST_REGION_ID,
ISNULL((1.96 * Stdev(WJXBFS1)), 0)
from [previous pass]
]
Pass7 - Execution Duration: 0:00:00.00
insert into ZZTS6MZ3N2BMD002 values (1, 127.4088118401)
Pass8 - Execution Duration: 0:00:00.00
create table ZZTSMWZF9SRMQ003 (
CUSTOMER_ID LONG)
Pass9 - Execution Duration: 0:00:00.36
insert into ZZTSMWZF9SRMQ003
select distinct pa11.[CUSTOMER_ID] AS CUSTOMER_ID
from [ZZT3WSP7T8BMD000] pa11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[ZZT36UF785VMD001] pa15,
[ZZTS6MZ3N2BMD002] pa16
where pa11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID] and
a14.[CUST_REGION_ID] = pa15.[CUST_REGION_ID] and
pa15.[CUST_REGION_ID] = pa16.[CUST_REGION_ID]
and (pa11.[WJXBFS1] &gt; (IIF(ISNULL(pa15.[WJXBFS1]), 0,
pa15.[WJXBFS1]) + IIF(ISNULL(pa16.[WJXBFS1]), 0,
pa16.[WJXBFS1])))
Pass10 - Execution Duration: 0:00:00.00
create table ZZTRX7EEWHNNB004 (
DAY_DATE TIMESTAMP,
CUSTOMER_ID LONG,
WJXBFS1 DOUBLE)
Pass11 - Execution Duration: 0:00:07.89
insert into ZZTRX7EEWHNNB004
select a11.[ORDER_DATE] AS DAY_DATE,
a11.[CUSTOMER_ID] AS CUSTOMER_ID,

Copyright © 2023 All Rights Reserved 101


Fu n ct io n s Refer en ce

sum((a11.[QTY_SOLD] * (a11.[UNIT_PRICE] -
a11.[DISCOUNT]))) AS WJXBFS1
from [ORDER_DETAIL] a11,
[ZZTSMWZF9SRMQ003] pa12
where a11.[CUSTOMER_ID] = pa12.[CUSTOMER_ID]
group by a11.[ORDER_DATE],
a11.[CUSTOMER_ID]
Pass12 - Execution Duration: 0:00:00.00
create table ZZTQFB0EMCJMB005 (
CUSTOMER_ID LONG,
WJXBFS1 TIMESTAMP)
Pass13 - Execution Duration: 0:00:00.59
insert into ZZTQFB0EMCJMB005
select pc11.[CUSTOMER_ID] AS CUSTOMER_ID,
max(pc11.[DAY_DATE]) AS WJXBFS1
from [ZZTRX7EEWHNNB004] pc11
group by pc11.[CUSTOMER_ID]
Pass14 - Execution Duration: 0:00:00.78
select distinct pa11.[CUSTOMER_ID] AS CUSTOMER_ID,
a13.[CUST_LAST_NAME] AS CUST_LAST_NAME,
a13.[CUST_FIRST_NAME] AS CUST_FIRST_NAME,
a15.[CUST_REGION_ID] AS CUST_REGION_ID,
a16.[CUST_REGION_NAME] AS CUST_REGION_NAME0,
pa11.[WJXBFS1] AS WJXBFS1
from [ZZTRX7EEWHNNB004] pa11,
[ZZTQFB0EMCJMB005] pa12,
[LU_CUSTOMER] a13,
[LU_CUST_CITY] a14,
[LU_CUST_STATE] a15,
[LU_CUST_REGION] a16
where pa11.[CUSTOMER_ID] = pa12.[CUSTOMER_ID] and
pa11.[DAY_DATE] = pa12.[WJXBFS1] and
pa11.[CUSTOMER_ID] = a13.[CUSTOMER_ID] and
a13.[CUST_CITY_ID] = a14.[CUST_CITY_ID] and
a14.[CUST_STATE_ID] = a15.[CUST_STATE_ID] and
a15.[CUST_REGION_ID] = a16.[CUST_REGION_ID]
Pass15 - Execution Duration: 0:00:00.00

Copyright © 2023 All Rights Reserved 102


Fu n ct io n s Refer en ce

[Populate Report Data]


Pass16 - Execution Duration: 0:00:00.00
drop table ZZT3WSP7T8BMD000
Pass17 - Execution Duration: 0:00:00.00
drop table ZZT36UF785VMD001
Pass18 - Execution Duration: 0:00:00.01
drop table ZZTS6MZ3N2BMD002
Pass19 - Execution Duration: 0:00:00.00
drop table ZZTSMWZF9SRMQ003
Pass20 - Execution Duration: 0:00:00.00
drop table ZZTRX7EEWHNNB004
Pass21 - Execution Duration: 0:00:00.00
drop table ZZTQFB0EMCJMB005

l Pass0 and Pass1 compute metric M10.

l Pass2 and Pass3 compute metric M07.

l Pass4, Pass5, Pass6, and Pass7 compute (1.96 * M08). The group-value
function for M08, StDev, is not supported by the database (Microsoft
Access) so it is calculated by Intelligence Server.

l Pass8 and Pass9 obtain the list of valuable customers, evaluating the filter
condition F03.

l Pass10, Pass11, Pass12, and Pass13 compute the Last Order Sales
metric.

l Pass 14 displays the results for the report.

l All other passes drop the temporary tables.

Statistical Descriptors - Simple Example


The report and report components used in this example can be found in the
MicroStrategy Tutorial project in the following folder:
MicroStrategy Tutorial\Public Objects\Reports\
MicroStrategy Platform Capabilities\Advanced Analytics\
Statistics and Forecasting\Statistical Descriptors

Copyright © 2023 All Rights Reserved 103


Fu n ct io n s Refer en ce

The Component Objects - Advanced folder contains additional


statistical descriptor examples.

How Do I Learn More About My Customers?


You can get more information about the customers in each region by
performing statistical calculations on their spending. This example uses
analysis to answer the following questions:

l How many customers exist in each customer region?

l What is the average spending of customers in each customer region?

l What is the median spending of customers in each customer region?

l What is the standard deviation of customer spending in each customer


region?

l How much is the 25th and 75th percentile of customer spending in each
customer region?

These are statistical descriptors about customers in each customer region.


This type of data can help you understand how customers spend their
money.

To answer the questions above, you must create a set of simple metrics
based on other metrics. These metrics are defined using nested group-value
functions.

1. This metric determines the number of customers in each region:


Count of Customers = Sum(Count(1) {~+, Customer+} )
{~+}

2. This metric determines the average spending of customers in each


region:
a.Mean Revenue Per Customer = Avg(Sum(Revenue) {~+,
Customer+} ) {~+}

Copyright © 2023 All Rights Reserved 104


Fu n ct io n s Refer en ce

3. This metric determines the median spending of customers in each


region:
b.Median Revenue Per Customer = Median(Sum(Revenue)
{~+, Customer+} ) {~+}

4. This metric determines the standard deviation of customer spending in


each region:

e.StDev of Revenue Per Customer = Stdev(Sum(Revenue)


{~+, Customer+} ) {~+}

5. This metric determines the threshold for the 25th percentile:


25th Percentile of Revenue Per Customer = Percentile
(Sum(Revenue) {~+, Customer+} , 0.25) {~+}

6. This metric determines the threshold for the 75th percentile:

75th Percentile of Revenue Per Customer = Percentile


(Sum(Revenue) {~+, Customer+} , 0.75) {~+}

Create a report and place all of the metrics described above on the row
axis and place the attribute Customer Region on the column axis.
Execute the Statistical Descriptors - Simple report, which is shown
below:

This report provides information on the behavior of customer spending


in each customer region. For example, the Northwest customer region
has the least number of customers, but most customers in that region
spend more than any other region, as seen in the larger mean and
median revenues per customer. This can highlight that it is worthwhile
to gain a larger customer base in this region.

Copyright © 2023 All Rights Reserved 105


Fu n ct io n s Refer en ce

However, the somewhat lower value for the standard deviation of


revenue per customer in the Northwest region also indicates that this
result might be due to the smaller sample size and a few customers that
spend abnormally large amounts. This standard deviation value helps
to show that while a campaign to increase the customer base in the
region is still an attractive idea, the results should be monitored to
determine if revenues continue to be higher per customer.

The SQL generated for the Statistical Descriptors - Simple report is as


follows:

Pass0 - Execution Duration: 0:00:00.00


create table ZZT42W71C95MD000 (
CUSTOMER_ID LONG,
WJXBFS1 LONG,
WJXBFS2 DOUBLE)
Pass1 - Execution Duration: 0:00:00.06
insert into ZZT42W71C95MD000
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
count(1.0) AS WJXBFS1,
sum(a11.[TOT_DOLLAR_SALES]) AS WJXBFS2
from [CUSTOMER_SLS] a11
group by a11.[CUSTOMER_ID]
Pass2 - Execution Duration: 0:00:00.09
select distinct pa11.[CUSTOMER_ID] AS CUSTOMER_ID,
a14.[CUST_REGION_ID] AS CUST_REGION_ID,
a15.[CUST_REGION_NAME] AS CUST_REGION_NAME0,
pa11.[WJXBFS1] AS WJXBFS1,
pa11.[WJXBFS2] AS WJXBFS2
from [ZZT42W71C95MD000] pa11,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[LU_CUST_REGION] a15
where pa11.[CUSTOMER_ID] = a12.[CUSTOMER_ID] and
a12.[CUST_CITY_ID] = a13.[CUST_CITY_ID] and
a13.[CUST_STATE_ID] = a14.[CUST_STATE_ID] and

Copyright © 2023 All Rights Reserved 106


Fu n ct io n s Refer en ce

a14.[CUST_REGION_ID] = a15.[CUST_REGION_ID]
Pass3 - Execution Duration: 0:00:00.00
[Analytical SQL calculated by the Analytical Engine:
select CUST_REGION_ID,
CUST_REGION_NAME0,
sum(WJXBFS1),
avg(WJXBFS2),
Median(WJXBFS2),
Stdev(WJXBFS2),
Percentile(WJXBFS2, 0.25),
Percentile(WJXBFS2, 0.75)
from [previous pass]
]
Pass4 - Execution Duration: 0:00:00.00
[Populate Report Data]
Pass5 - Execution Duration: 0:00:00.00
drop table ZZT42W71C95MD000

l The first two passes of SQL (Pass0 and Pass1) prepare and calculate the
values used in other metrics.

l The Intelligence Server optimizes the process by pulling only a single


column of revenue data even though it is used in several other metrics.

l In Pass2 and Pass3 the Intelligence Server retrieves the results from
Pass1 to compute the other metrics. In Pass3 the Intelligence Server acts
as an in-memory database, using the values from Pass2 to calculate the
following group-value functions: Sum, Avg, Median, Stdev, and Percentile.

l The remaining passes prepare the report and drop the temporary tables.

Forecasting Example
The report and report components in this example can be found in the
MicroStrategy Tutorial project in the following folder:
MicroStrategy Tutorial\Public Objects\Reports\
MicroStrategy Platform Capabilities\Advanced Analytics\
Statistics and Forecasting\Forecasting

Copyright © 2023 All Rights Reserved 107


Fu n ct io n s Refer en ce

How to Forecast Future Sales Based on Existing Sales Data?


The MicroStrategy Tutorial project has sales data for multiple years. Using
this data, you can forecast potential sales for the upcoming years.

To plot a sales line for the expected future sales data, apply linear
extrapolation techniques to the historical data. Linear extrapolation involves
the assumption that the trend of past data will continue in a linear fashion.
The slope and Y-intercept values are calculated based on historical data,
and the same slope and Y-intercept are applied to extend the data into the
future.

This is just one type of forecasting analysis that can be done in


MicroStrategy. There are additional MicroStrategy functions that provide
other variations on calculating a forecast of values. For information on these
functions, how they forecast values, and forecasting examples using these
functions, see:

l ForecastV (Forecast, Vector Input), page 453

l GrowthV (Growth, Vector Input), page 459

l TrendV (Trend, Vector Input), page 488

To perform the analysis, build a set of metrics that calculate each of the
components in the analysis, then use those metrics together to create the
final Forecasting metric.

1. The metric that calculates sales revenue at the Year level is defined as
follows:
Revenue {Year} = Sum(Revenue) {~+, Year+}

2. The metric that expresses the Year elements as a series of integers, to


simplify the analysis, is defined as follows:
YearNumber = RunningSum<SortBy= (Year@ID) >(Sum(1)
{~+, Year } )

Copyright © 2023 All Rights Reserved 108


Fu n ct io n s Refer en ce

3. The metric that calculates the slope of the line produced by the
Revenue {Year} metric is defined as follows:

SlopeMetric= Slope([Revenue {Year}], YearNumber) {~+,


!Year+}

4. The metric that calculates the Y-intercept of the line produced by the
Revenue {Year} metric is defined as follows:

InterceptMetric = Intercept([Revenue {Year}],


YearNumber) {~+, !Year+}

5. The final metric combines the three preceding metrics into a forecast
value. This formula follows the standard formula for a line: y = mx +
b. The metric is defined as follows:

Forecast = ((SlopeMetric * YearNumber) +


InterceptMetric)

Place the Forecast metric on a report with Year. A sales forecast is


generated for all available years. The Forecast (Graph) report displays
as follows:

Copyright © 2023 All Rights Reserved 109


Fu n ct io n s Refer en ce

The sales for 2008, 2009, and 2010 are actual recorded values, and the
sales for 2011 are a linear extrapolation of the existing data into the
future.

The following SQL is generated for the Forecast (Graph) report:

Pass0 - Execution Duration: 0:00:00.20


create table ZZT16JMSID1MD000 (
YEAR_ID SHORT,
CATEGORY_ID SHORT,
WJXBFS1 DOUBLE)
Pass1 - Execution Duration: 0:00:00.10
insert into ZZT16JMSID1MD000
select a11.[YEAR_ID] AS YEAR_ID,
a11.[CATEGORY_ID] AS CATEGORY_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [YR_CATEGORY_SLS] a11
Pass2 - Execution Duration: 0:00:00.23
select a12.[YEAR_ID] AS YEAR_ID,
a11.[CATEGORY_ID] AS CATEGORY_ID,
1.0 AS WJXBFS1
from [LU_CATEGORY] a11,
[LU_YEAR] a12
Pass3 - Execution Duration: 0:00:00.00
create table ZZT3M2QSNWDMD001 (
YEAR_ID SHORT,
CATEGORY_ID SHORT,
WJXBFS1 DOUBLE)
Pass4 - Execution Duration: 0:00:00.00
[Analytical SQL calculated by the Analytical Engine:
select YEAR_ID,
CATEGORY_ID,
RunningSum&lt;SortBy= ([YEAR_ID])&gt;(WJXBFS1)
from [previous pass]
]
Pass5 - Execution Duration: 0:00:00.00
insert into ZZT3M2QSNWDMD001 values (2008, 1, 1)
Pass6 - Execution Duration: 0:00:00.00

Copyright © 2023 All Rights Reserved 110


Fu n ct io n s Refer en ce

create table ZZTDMBESMXPOJ002 (


YEAR_ID SHORT,
CATEGORY_ID SHORT)
Pass7 - Execution Duration: 0:00:00.00
insert into ZZTDMBESMXPOJ002
select pa11.[YEAR_ID] AS YEAR_ID,
pa11.[CATEGORY_ID] AS CATEGORY_ID
from [ZZT16JMSID1MD000] pa11
Pass8 - Execution Duration: 0:00:00.00
insert into ZZTDMBESMXPOJ002
select pa11.[YEAR_ID] AS YEAR_ID,
pa11.[CATEGORY_ID] AS CATEGORY_ID
from [ZZT3M2QSNWDMD001] pa11
Pass9 - Execution Duration: 0:00:00.00
create table ZZT9MCAB4STOD003 (
YEAR_ID SHORT,
CATEGORY_ID SHORT)
Pass10 - Execution Duration: 0:00:00.00
insert into ZZT9MCAB4STOD003
select distinct pa11.[YEAR_ID] AS YEAR_ID,
pa11.[CATEGORY_ID] AS CATEGORY_ID
from [ZZTDMBESMXPOJ002] pa11
Pass11 - Execution Duration: 0:00:00.00
select pa11.[YEAR_ID] AS YEAR_ID,
pa11.[CATEGORY_ID] AS CATEGORY_ID,
pa12.[WJXBFS1] AS WJXBFS1,
pa13.[WJXBFS1] AS WJXBFS2
from [ZZT9MCAB4STOD003] pa11,
[ZZT16JMSID1MD000] pa12,
[ZZT3M2QSNWDMD001] pa13
where pa11.[CATEGORY_ID] = pa12.[CATEGORY_ID] and
pa11.[YEAR_ID] = pa12.[YEAR_ID] and
pa11.[CATEGORY_ID] = pa13.[CATEGORY_ID] and
pa11.[YEAR_ID] = pa13.[YEAR_ID]
Pass12 - Execution Duration: 0:00:00.00
create table ZZTMYCAAR65MD004 (
CATEGORY_ID SHORT,

Copyright © 2023 All Rights Reserved 111


Fu n ct io n s Refer en ce

WJXBFS1 DOUBLE,
WJXBFS2 DOUBLE)
Pass13 - Execution Duration: 0:00:00.00
[Analytical SQL calculated by the Analytical Engine:
select CATEGORY_ID,
Slope(WJXBFS1, WJXBFS2),
Intercept(WJXBFS1, WJXBFS2)
from [previous pass]
]
Pass14 - Execution Duration: 0:00:00.00
insert into ZZTMYCAAR65MD004 values (1,
58938.0812500116, 585341.077083335)
Pass15 - Execution Duration: 0:00:00.04
select pa11.[CATEGORY_ID] AS CATEGORY_ID,
a13.[CATEGORY_DESC] AS CATEGORY_DESC0,
pa11.[YEAR_ID] AS YEAR_ID,
(IIF(ISNULL((pa12.[WJXBFS1] * pa11.[WJXBFS1])), 0,
(pa12.[WJXBFS1] * pa11.[WJXBFS1])) +
IIF(ISNULL(pa12.[WJXBFS2]), 0, pa12.[WJXBFS2])) AS
WJXBFS1
from [ZZT3M2QSNWDMD001] pa11,
[ZZTMYCAAR65MD004] pa12,
[LU_CATEGORY] a13
where pa11.[CATEGORY_ID] = pa12.[CATEGORY_ID] and
pa11.[CATEGORY_ID] = a13.[CATEGORY_ID]
Pass16 - Execution Duration: 0:00:00.00
[Populate Report Data]
Pass17 - Execution Duration: 0:00:00.00
drop table ZZT16JMSID1MD000
Pass18 - Execution Duration: 0:00:00.00
drop table ZZT3M2QSNWDMD001
Pass19 - Execution Duration: 0:00:00.00
drop table ZZTDMBESMXPOJ002
Pass20 - Execution Duration: 0:00:00.00
drop table ZZT9MCAB4STOD003
Pass21 - Execution Duration: 0:00:00.00
drop table ZZTMYCAAR65MD004

Copyright © 2023 All Rights Reserved 112


Fu n ct io n s Refer en ce

l Pass0 and Pass1 calculate the Revenue {Year} metric.

l Pass2 calculates the inner portion of the YearNumber metric, assigning


the integer 1 to each year available in the LU_YEAR lookup table. Note that
this metric was defined by adding Year dimensionality with filtering set to
None. This forces the metric into its own pass of SQL, to ensure that all
years in the lookup table are numbered, not just the years with data in the
fact table.

l Passes 3 to 14 calculate the metrics YearNumber, SlopeMetric, and


InterceptMetric. The Intelligence Server performs the calculations based
on the data in the temporary table from Pass0, Pass1, and Pass2. Values
are calculated and inserted back into the temporary tables.

l In Pass15, the Forecast metric is calculated based on the information from


all of the previous calculations. The mx+b calculation is performed as part
of the SQL statement.

l The remaining passes prepare the report and drop the temporary tables.

Copyright © 2023 All Rights Reserved 113


Fu n ct io n s Refer en ce

STAN D ARD FUN CTION S

Copyright © 2023 All Rights Reserved 114


Fu n ct io n s Refer en ce

The standard functions in this chapter range from simple operations like Sum
and Product to internal functions that allow you to define your own metrics,
facts, and filters. Taken as a set, they provide a powerful toolset for
performing common mathematical calculations, grouping data, examining
correlation, validating data, and formatting report information for display.

The following categories of functions are covered:

l Basic Functions, page 116

l Date and Time Functions, page 149

l Internal Functions, page 169

l NULL/Zero Functions, page 188

l OLAP Functions, page 191

l Rank and NTile Functions, page 268

l String Functions, page 293

Each section in this chapter describes a function category and presents a


list of functions within each category. Each section also presents the data
necessary to understand and implement each individual function. The
information provided for each function includes

l An explanation of the data returned by the function

l The syntax of the function including function name, available parameters,


the parameter setting defaults, and the types of data that can be used with
the function

l The mathematical expression illustrating exactly how the calculation is


defined in MicroStrategy (if applicable)

l Usage notes describing any error conditions, invalid data types, or key
information to know before using the function (if applicable)

l An example of the function in use; this may be either a report example or a


simple text description of the data returned based on the specified input

Copyright © 2023 All Rights Reserved 115


Fu n ct io n s Refer en ce

l The report examples in this section use objects and data found in the
MicroStrategy Tutorial.

l See Appendix A, MicroStrategy and Database Support for Functions, for a


list of the databases and the functions they support.

Basic Functions
These are basic mathematical functions like Avg, Greatest, Least, Max, Min,
and so on, and are among the most commonly used functions.

Add
Returns the sum of two or more values. The Add function differs from the
Sum function (see Sum , page 144), which returns the sum of values in a
single value list. Add can take multiple metrics as inputs and add the values
of the metrics.

You can also construct these types of metrics using the plus operator (see
Plus (+), page 322) instead of the Add function.

Syntax

Add(Argument1, Argument2,..., ArgumentN)

Where

The arguments must be metrics or constants.

Example

You can use the Add function to return the sum of related metrics. In the
report shown below, the Total Paid Compensation metric uses the formula
Add([Paid Bonus],[Paid Salary]) to return the total compensation
paid to each employee. This report was created in the MicroStrategy Human
Resources Analysis Module.

Copyright © 2023 All Rights Reserved 116


Fu n ct io n s Refer en ce

Average
Average performs a sum of a set of values and divides this total by the
number of values in the set. This returns the average (also known as
arithmetic mean) for the set of values.

The Average function differs from the Avg function (see Avg (Average),
page 117), which returns the average of values in a single value list. The
Average function can take multiple metrics as inputs and average the
values of the metrics. You can use this function to compute and display the
average of two or more metrics on a report.

Syntax

Average(Argument1, Argument2,..., ArgumentN)

Where:

The arguments must be metrics or constants.

Avg (Average)
Avg calculates the sum of a single value list and divides the result by the
number of values in the list. This returns the average (arithmetic mean) of
the listed values.

Copyright © 2023 All Rights Reserved 117


Fu n ct io n s Refer en ce

Avg is often used to create subtotals and metrics based on fact data. This is
a group-value function.

To calculate an average while applying a weight to the values, see


WeightedMean, page 260.

Syntax

Avg<Distinct, FactID

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l Distinct is a TRUE/FALSE parameter that allows you to use all values in


the calculation or to calculate using only the unique values.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Usage Notes

The Avg function ignores NULL values but uses zero values in its
calculation.

Example

Example 1: In this simple example the average of a value list containing the
values (4,9,2,9) is calculated as follows:

(4+9+2+9)/4 = 6

Example 2: This report obtains the average salary for employees in each
region. The report contains the attributes Region, Employee, and Salary as
well as the metric Average Salary. A report filter limits the regions displayed
to Northeast and Southeast. The metric Average Salary is defined as
follows: Avg(Salary){Region}

The function sums all salaries within a region and divides by the number of
values, resulting in the regional average salary.

Copyright © 2023 All Rights Reserved 118


Fu n ct io n s Refer en ce

For further examples of using the Avg function, see Example 1: Transformed
Fact, page 12 and Example 2: Compound Metric, page 13, as well as
Example 1: Average, page 14.

Condition
Condition is a shortcut function, available for various features in
MicroStrategy Web, that allows you to easily define the condition (filtering)
of the final metric expression. A conditional metric allows you to apply a
filter to only one metric on a report without affecting the other metrics. The
metric filter can be either a filter or a prompt that returns a list of filters to
choose from. Only one filter or prompt can be associated with each metric,
but the metric filter can contain multiple qualifications. For additional
information on when to create conditional metrics, see the Advanced
Reporting Guide.

Once you select the Condition shortcut function, you can then select the
group function for the calculation, such as Sum or Max. Additionally, the
options to add or remove a condition are displayed:

l To add a condition to the metric, click the Browse icon ( ) to select a


filter or a prompt that returns a list of filters.

l To remove the condition from a metric, click the Delete icon ( ).

You can also define how the condition is evaluated by clicking Condition
advanced options:

Copyright © 2023 All Rights Reserved 119


Fu n ct io n s Refer en ce

l By default, the parts of the report filter that are based on parent or child
attributes of the attribute in the metric condition are ignored, and do not
affect the calculation of the conditional metric. To apply all criteria in the
report filter to the conditional metric, clear the Ignore related report filter
elements check box. This option is selected by default.

l By default, the report filter is applied to the metric data and then the metric
filter is applied to those results. You can determine the order in which the
report filter and metric filter are applied to the metric. From the
Interaction between metric filter and report filter drop-down list, select
one of the following:

l To apply the report filter criteria first, then apply the metric filter to the
results, select Merge report filter into metric (default). For example,
the metric filter is revenue greater than $100 and the report filter is
bottom 10 items for sales. In this example, the report filter narrows the
result set to only 10 items, and then the metric condition filters out, from
those 10 items, any items with a revenue above $100.

l To evaluate the metric filter first, then apply the report filter to the
results, select Merge metric condition into report. Using this option
with the example above, the metric condition returns all items with a
revenue above $100. The report filter then filters out all but the bottom
10 of those items, based on sales.

l To combine the metric filter and the report filter, select Merge into new.
Only those results that meet both the metric filter and the report filter are
included in the metric. Using this option with the example above, the two
filters are merged, so that only those items that are in the bottom 10 in
terms of sales and that have sales greater than $100 are included.

Count
Count returns the number of elements in a list of values. This is a group-
value function.

Syntax

Copyright © 2023 All Rights Reserved 120


Fu n ct io n s Refer en ce

Count<Distinct, FactID, UseLookupForAttributes, Null>


(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of values.

l Distinct is a TRUE/FALSE parameter that allows you to count all


elements in a list or only the unique elements.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

l UseLookupForAttributes is a TRUE/FALSE parameter that can be


used when performing an aggregation of an attribute:

l If you set this parameter to TRUE, the aggregation is done for the unique
set of attribute elements, excluding any duplicates caused by additional
attributes on the report.

l If you set this parameter to FALSE, the aggregation is done for all
elements of an attribute, including duplicate elements that can be
included by displaying additional attributes on a report.

For an example of how to use this parameter, see Performing Counts of


Attributes, page 122.

Example

This example creates a report that calculates the count of employees in


each region. The report contains the attributes Region and Employee, and
the metric # of Employees. A report filter limits the regions displayed to
Central, South, Southeast, and Southwest. The metric # of Employees is
defined as follows: Count(Employee){Region, ~}.

The function counts each entry within a region and returns the last number in
the count.

Copyright © 2023 All Rights Reserved 121


Fu n ct io n s Refer en ce

Performing Counts of Attributes


While most functions are commonly used with facts and metrics, the Count
function is commonly used to count the number of elements for an attribute.
For example, the report shown below displays the customer revenue for
each item they purchased.

Copyright © 2023 All Rights Reserved 122


Fu n ct io n s Refer en ce

This report also uses two derived metrics to display the following count
information:

l Number of Customers: This derived metric displays the count of


customers. The expression used to define the derived metric is
Count<UseLookupForAttributes=True>(Customer){}. By defining
the parameter UseLookupForAttributes=True, the Count function
ignores any multiple listings of each Customer attribute element. In the
report shown above, each separate item is ignored and only the unique
attribute elements for Customer are counted.

l Number of Customer Purchases: This derived metric displays the count


of customer purchases. The expression used to define the derived metric
is Count<UseLookupForAttributes=False>(Customer){}. By
defining the parameter UseLookupForAttributes=False, the Count
function counts each listing of the Customer attribute element. In the
report shown above, each separate item is counted, which provides a
count of customer purchases.

For information on creating derived metrics, along with other OLAP Services
features, see the In-memory Analytics Guide.

First
Returns the result of an aggregate applied over a set of rows that ranks as
the first within a specified order. This is a group-value function that shares
the sort by capability of the OLAP functions.

Syntax

First<FactID, SortBy>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of values.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Copyright © 2023 All Rights Reserved 123


Fu n ct io n s Refer en ce

l SortBy is a parameter that allows you to define the attribute or metric on


which to sort the data.

Example

The First function is often used to define subtotals. In this example, the First
function defines the subtotal for the metric units received, returning the units
received for the first quarter containing a value in 2003. The expression
defines the subtotal as follows:

First<SortBy= (Day, Month, Quarter, Year) >([Units Received]){@}

Argument is the metric to which the subtotal is applied.

For detailed instructions on creating and applying user-defined subtotals,


see the MicroStrategy Advanced Reporting Guide.

Copyright © 2023 All Rights Reserved 124


Fu n ct io n s Refer en ce

GeoMean (Geometric Mean)


This function can be used to find the average for a set of values contributing
to a product. While the Avg function is used to find the arithmetic mean for a
set of values contributing to a sum, GeoMean can be used to determine the
average growth rate for a given compound interest with variable rates.

This function takes the product of a set of values of size N and returns the
Nth root of the result (also known as geometric mean). GeoMean is a group-
value function.

Syntax

GeoMean <FactID>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Usage Notes

This function returns an error if a value in the value list is negative.

Example

Suppose you have an investment that earns 10% the first year, 60% the
second year, and 20% the third year, and you want to answer the question
"What is its average rate of return?" You do not want to use the Avg function
to obtain the arithmetic mean, because these numbers show that in the first
year your investment was multiplied by 1.10, in the second year by 1.60, and
in the third year by 1.20. The average is the geometric mean of these three
numbers. This can be understood as looking for a constant that you can

Copyright © 2023 All Rights Reserved 125


Fu n ct io n s Refer en ce

multiply each year's investment by, and get the same result as multiplying
the first year by 1.10, the second year by 1.60, and so forth. This constant is
the geometric mean.

(1.10 * 1.60 * 1.20) 1/3 = 1.283

The geometric mean is 1.283, so the average rate of return is about 28%.

Greatest
Returns the larger of two or more values. The Greatest function differs
from the Max function, which returns the largest value in a single value list.
Greatest can take multiple lists as input and compare the elements in the
lists. It is used for comparisons between metrics.

Syntax

Greatest(Argument1, Argument2,..., ArgumentN)

Where:

The arguments must be metrics.

Example

This simple example illustrates how data is returned by the Greatest


function.

Given two value lists, the function compares the values in each position in
the list and returns a list containing the highest numbers from each position.

Result
List 1 List 2
List

21 50 50

18 3 18

42 22 42

30 6 30

7 20 20

Copyright © 2023 All Rights Reserved 126


Fu n ct io n s Refer en ce

Histogram Median
Histogram Median is a distributive implementation to calculate
approximation of median over large datasets.

Formula

Where:

L m is the lower limit of the median bar.

n is the total number of observations in the set.

F m-1 is the total number of observations in all bars below the median bar.

f m is the frequency of the median bar.

c is the median bar width.

Syntax

HistogramMedian([ValueList], NumberOfHistograms)

Where:

ValueList is an attribute, fact, or metric representing a list of values.

NumberOfHistograms represents the histograms to be analyzed.

Example

This example shows a report to find the median Revenue per Customer for
each Income Bracket in the Central Region.

HistogramMedian([Max Revenue per Customer], [Max Revenue


per Customer]) {~ , Region}

Copyright © 2023 All Rights Reserved 127


Fu n ct io n s Refer en ce

Last
The Last function returns the last value in a sorted set of values. It is often
used to define subtotals, as shown in the example below. This is a group-
value function.

Syntax

Last<FactID, SortBy>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of values.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

l SortBy is a parameter that allows you to define the attribute or metric on


which to sort the data.

Example

In this example, Last is used in the subtotal for the metric End on Hand,
returning the total items on hand in the last quarter of 2003. The subtotal
expression is defined as follows:

Last<SortBy= (Day, Month, Quarter, Year) >(End on Hand) {@ }

For detailed instructions on creating and applying user-defined subtotals,


see the MicroStrategy Advanced Reporting Guide.

Copyright © 2023 All Rights Reserved 128


Fu n ct io n s Refer en ce

Least
This function returns the smaller of two or more values. The Least function
differs from the Min function, which returns the smallest value in a single
value list. Least can take multiple lists as input and compare the elements
of the lists. It is used for comparisons between metrics. This is a single-
value function.

Syntax

Least(Argument1, Argument2,..., ArgumentN)

Where:

The arguments must be metrics.

Example

This simple example illustrates how data is returned by the Least function.

Copyright © 2023 All Rights Reserved 129


Fu n ct io n s Refer en ce

Given two values lists, the function compares the values at each position in
the lists and returns a list of the lowest values from each position.

Result
List 1 List 2
List

21 50 21

18 3 3

42 22 22

30 6 6

7 20 7

Level
Level is a shortcut function, available for various features in MicroStrategy
Web, that allows you to easily define the level (dimensionality) of the final
metric expression. The level of a metric determines the conceptual level at
which a calculation is performed. For example, rather than just calculating
your revenue, you want to specify that a metric always calculates yearly
revenue. For additional information on when to create level metrics, see the
Advanced Reporting Guide.

Once you select the Level shortcut function, you can then select the group
function for the calculation, such as Sum or Max. Additionally, the options to
add and remove levels are displayed:

l Report Level is the default level. If you remove Report Level as a level of
the metric, you can add it back by typing Report Level in the level text
field.

l To add a level to the metric, click the Browse icon ( ) to select an


attribute.

l To remove a level from a metric, click the Delete icon ( ).

You can also define how levels are evaluated:

Copyright © 2023 All Rights Reserved 130


Fu n ct io n s Refer en ce

l To define the level options, for each level, click the Level options icon (
).

Drop-down List Level Options

To include only data that meets the conditions in the report filter in
the metric calculation, select Standard filtering.

To raise the level of the report filter to the level of the target, if
possible, then apply the report filter to the metric calculation, select
Absolute filtering. For example, the report filter contains the
Washington, DC, Boston, and New York call centers, but the
Revenue metric is calculated at the Region level. Because Call
Center is a child attribute of Region, the report filter's level is raised
From the to the Region level, and the report filter is treated as if it includes the
Relationship with regions that contain Washington, DC, Boston, and New York (in this
Report Filter drop- case, Mid-Atlantic and Northeast). Data from all call centers in the
down list, you can Mid-Atlantic or Northeast regions are included in the metric
define how the calculation, including call centers that are not Washington, DC,
report filter affects Boston, or New York.
the metric
calculation. To ignore any conditions in the report filter that are based on the
target attribute, as well as any parent or child attributes of the
target, select Ignore filtering. For example, if you have a regional
revenue metric on a report, any conditions based on Country,
Region, or Call Center in the report filter are ignored when
calculating the metric. However, a condition based on Year would
not be ignored, since Year is not directly related to Region.

To allow the target and group components of the level to define the
filter, select None.

From the Metric


Aggregations
drop-down list, you
can determine how To group data in the metric by the attribute level of the target, select
the metric is Standard.
grouped, or
aggregated, when
displayed on a

Copyright © 2023 All Rights Reserved 131


Fu n ct io n s Refer en ce

Drop-down List Level Options

To exclude the target attribute from being used to group data in the
metric, select None. Any children of the target attribute are also
excluded. This option is available for metrics calculated at a set
level, as opposed to the report level.

The following options are only used for nonaggregatable metrics. A


nonaggregatable metric, such as an inventory metric, is one that
should not be aggregated across an attribute. For example, if you
have monthly inventory numbers in your data warehouse and want
to calculate the yearly inventory, adding the monthly numbers
report. together does not provide a useful business measure. Instead, you
may want to use the end-on-hand and beginning-on-hand inventory
numbers to see how the total inventory changed during the year.
The following options are available:

• To use the first value in the lookup table, select Beginning


lookup.

• To use the last value in the lookup table, select Ending lookup.

• To use the first value in the fact table, select Beginning fact.

• To use the last value in the fact table, select Ending fact.

l To define the advanced level options, such as whether to apply the metric
filter to the metric calculation, click Level advanced options:

l Allow other users to add extra units to this definition: This option is
used to emulate MicroStrategy 6.x behavior and affects only those
projects that have been upgraded from 6.x. Clear the check box only if
your project was upgraded from MicroStrategy 6.x. This option is
selected by default.

l Include filter attributes which are not in report or level in metric


calculation: Determine whether to apply the metric filter when the
metric is calculated. If this option is cleared, filter attributes that are not
on the report or in the level of the metric are not included in the metric

Copyright © 2023 All Rights Reserved 132


Fu n ct io n s Refer en ce

calculation. This options lets you determine which parts of the metric
filter are applied based on the data that has been included on the report.
This option can help you re-use the same metric in multiple reports,
eliminating the need to create and maintain multiple metrics, particularly
if the metric and filter qualifications are complex. For an example,
including an explanation of how the report SQL is affected by this option,
see the Advanced Reporting Guide. This option is selected by default.

Max (maximum)
Max returns the largest value in a list of values. For example, it can be used
on a list of prices to determine the maximum cost of an item. This is a group-
value function.

To compare the highest values in multiple lists of values, use the Greatest
function.

Syntax

Max <FactID

Where:

l Argument is an attribute, fact or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Example

This example shows a dossier grid displaying the sales range of items within
a subcategory (Aisle). The Max function is used to determine the highest
sales of an item within a subcategory. The metric, Maximum Sale, is defined
as follows:

Max (Sales){~}

Copyright © 2023 All Rights Reserved 133


Fu n ct io n s Refer en ce

The metric is placed on the grid with the attributes Department and Aisle and
the metrics Sale Total and Minimum Sale. The resulting grid appears as
follows:

Median
Median returns the value in the middle of a set of listed values. The result
will be greater than half the values in the list and less than the other half.
The median can be used as an alternative to the arithmetic mean when
handling values that are not evenly distributed or contain outliers. This is a
group-value function.

Syntax

Median <FactID>(Argument}

Where:

Copyright © 2023 All Rights Reserved 134


Fu n ct io n s Refer en ce

l Argument is an attribute, fact or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Usage Notes

This function provides a location measure: the value returned has a relative
position with regard to other values in the list. Mode is another function that
provides a location measure.

Example

This example shows a report built to obtain the median age of employees
within each region. The report includes the attributes Region, Employee,
and Employee Age, and the metric Median Age. A report filter limits the
regions displayed to Mid Atlantic, Northeast, and Southeast. The metric
Median Age is defined as follows:

Median([Employee Age){Region,~}

The function evaluates the list of employee ages within a region and selects
a value in the middle of the value list.

Copyright © 2023 All Rights Reserved 135


Fu n ct io n s Refer en ce

For another example of using the Median function, see Example 2: Median,
page 14.

Min (minimum)
Min returns the lowest value in a list of values. For example, it can be used
on a list of prices to determine the minimum cost of an item. This is a group-
value function.

To compare the lowest values in multiple lists of values, use the Least
function.

Syntax

Min <FactID, NullInclude>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

l NullInclude is a parameter that determines how NULL values are


included in the calculation.

Example

This example shows a report displaying the cost range of items within a
subcategory. The Min function is used to determine the lowest cost of an
item within a subcategory. The metric Minimum Unit Cost is defined as
follows:

Minimum([Unit Cost]) {~}

The metric is placed on a report with the attributes Category and


Subcategory and the metric Maximum Unit Cost.

Copyright © 2023 All Rights Reserved 136


Fu n ct io n s Refer en ce

Mode
Returns the most frequently occurring value in a given list. This is a group-
value function.

Syntax

Mode <FactID, IsRemovable>(Argument)

Where:

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

l IsRemovable is a parameter that determines whether the Mode of a


single value returns that value or a NULL value, as described below:

Copyright © 2023 All Rights Reserved 137


Fu n ct io n s Refer en ce

l IsRemovable=True returns the single value as the result of the Mode


function. For example, Mode<IsRemovable=True>(4) would return
the value 4.

l IsRemovable=False returns a NULL value as the results of the Mode


function when a single value is supplied. For example,
Mode<IsRemovable=False>(4) would return NULL.

If multiple values are supplied to the Mode function, the IsRemovable


parameter has no effect on the result of the Mode function.

l Argument is an attribute, fact, or metric representing a list of numbers.

Usage Notes

l This function provides a location measure: the value returned has a


relative position with regard to other values in the list. Median is another
function that provides a location measure.

l Returns a NULL if there are no recurring values in the range or list.

Example

This example shows a report that retrieves the mode of the unit cost for
items in a subcategory. The report returns the most frequently repeated unit
cost within the various subcategories, and, in the cases of Electronics, TVs,
and Video Equipment, it returns a NULL value, because there are no
recurring unit cost values for them. The report contains the attributes
Category and Subcategory, and the metric Mode Unit Cost. A report filter
limits the categories displayed to Books and Electronics. The Mode Unit
Cost metric is defined as follows:

Mode([Unit Cost])

The formula listed above uses the Unit Cost fact rather than the Unit Cost
metric.

Copyright © 2023 All Rights Reserved 138


Fu n ct io n s Refer en ce

Multiply
Multiply returns the product of two or more values. This function differs
from the Product function (see Product, page 140), which returns the
product of values in a single value list. The Multiply function can take
multiple metrics as inputs and multiply the values of the metrics.

You can also construct these types of metrics using the times operator (see
Times (*), page 321) rather than the Multiply function.

Syntax

Multiply(Argument1, Argument2,..., ArgumentN)

Where:

The arguments must be metrics or constants.

Example

In the report shown below, the Unit Profit metric uses the formula Multiply
([Unit Price],[Units Sold]) to return the revenue for each item. This
report was created in the MicroStrategy Tutorial project.

Copyright © 2023 All Rights Reserved 139


Fu n ct io n s Refer en ce

Product
Multiplies all values in a list. This is a group-value function.

Syntax

Product<FactID>(Argument)

Where

l Argument is an attribute, fact, or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Example

Given a value list containing the values (1,2,3,4), the product calculates as
1*2*3*4 = 24.

StDevP (Standard Deviation of a Population)


The standard deviation is a value which shows how widely values in a
population differ from the mean. It is useful for comparing different sets of
values with a similar mean.

StDevP returns the standard deviation of a population represented by list of


values. It is a group-value function.

Syntax

Copyright © 2023 All Rights Reserved 140


Fu n ct io n s Refer en ce

StDevP <FactID >(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Usage Notes

l For this function, arguments correspond to an entire population as


opposed to a population sample. For population samples, see StDev
(Standard Deviation of a Sample), page 142.

l When very large population samples are used, this function and the StDev
(Standard Deviation of a Sample), page 142 function return approximately
equal results.

Example

This example shows a report where the standard deviation of the revenue is
calculated. This calculation is based on the assumption that the list of
values supplied in the metric represents the entire population of the data for
which you want to obtain the standard deviation. The calculation is based on
the revenue values for each state within a region and calculated at the
region level.

Compare this example report to the example for StDev to see the different
values returned when calculating for a population as opposed to a sample.

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue and StDevP. A report filter limits the regions

Copyright © 2023 All Rights Reserved 141


Fu n ct io n s Refer en ce

displayed to South, Northwest, and Southwest. The definition of the StDevP


metric is as follows:

StDevP([Total Revenue]){[Customer Region], ~}

StDev (Standard Deviation of a Sample)


The standard deviation is an indicator of how widely values in a group differ
from the mean. It is useful for comparing different sets of values with a
similar mean.

StDev returns the standard deviation of a population based on a sample.


This is a group-value function.

Syntax

StDev <Distinct, FactID>(Argument)

Where:

Copyright © 2023 All Rights Reserved 142


Fu n ct io n s Refer en ce

l Argument is an attribute, fact, or metric representing a list of numbers.

l Distinct is a TRUE/FALSE parameter that allows you to calculate using


all values in the list or only the unique values.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Usage Notes

l In this function, arguments correspond to a population sample as opposed


to the entire population. For entire populations, see StDevP (Standard
Deviation of a Population), page 140.

l To perform a weighted standard deviation, see WeightedStDev (Weighted


Standard Deviation of a Sample), page 262.

l When very large population samples are used, this function and the
StDevP (Standard Deviation of a Population), page 140function return
approximately equal results.

Example

This example shows a report where the standard deviation of the revenue is
calculated. This calculation is based on the assumption that the list of
values supplied in the metric represents a sample of the data for which you
want to obtain the standard deviation. The calculation is based on the
revenue values for each state within a region and calculated at the region
level.

Compare this example report to the example for StDevP to see the different
values returned when calculating for a population as opposed to a sample.

Copyright © 2023 All Rights Reserved 143


Fu n ct io n s Refer en ce

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue and StDev. A report filter limits the regions
displayed to South, Northwest, and Southwest. The definition of the StDev
metric is as follows:

StDev([Total Revenue]){[Customer Region], ~}

Sum
Returns the sum of all numbers in a list of values. This function is commonly
used in metrics and subtotals. Sum is a group-value function.

Syntax

Sum <Distinct, FactID

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l Distinct is a TRUE/FALSE parameter that allows you to calculate using


all values in the list or only the unique values.

Copyright © 2023 All Rights Reserved 144


Fu n ct io n s Refer en ce

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Example

In this example, the metric Regional Revenue is defined as follows:

Sum(Revenue) {[Customer Region], ~}

This simple report uses the attributes Customer Region and Customer State,
and the metrics Revenue and Regional Revenue to generate a report
showing the sum of the revenue for several regions. A report filter limits the
regions displayed to Northeast, Northwest, and Southeast.

Transformation
Transformation is a shortcut function, available for various features in
MicroStrategy Web, that allows you to easily define transformations for the
final metric expression. Transformations allow you to apply an attribute-
element based offset to compare metric data. For example, a transformation
metric can help a user compare last month's revenue to this month's
revenue. Although transformations can be applied to any attribute hierarchy,
the Time hierarchy is used most often. For the Time hierarchy, the offset can
be set as a fixed number of days, weeks, months, or years. For additional

Copyright © 2023 All Rights Reserved 145


Fu n ct io n s Refer en ce

information on when to create transformation metrics, see the Advanced


Reporting Guide.

Once you select the Transformation shortcut function, you can then
select the group function for the calculation, such as Sum or Max.
Additionally, the options to add or remove a transformation are displayed:

l To add a transformation to the metric, click the Browse icon ( ) to select


a transformation.

l To remove a transformation from a metric, click the Delete icon ( ).

VarP (Variance of a Population)


Variance is a measure of how spread out a set of values is.

VarP returns this measure based on an entire population. This is a group-


value function.

Syntax

VarP <FactID>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Usage Notes

Copyright © 2023 All Rights Reserved 146


Fu n ct io n s Refer en ce

For this function, arguments relate to an entire population as opposed to a


population sample.

Example

Variance is calculated as the average squared deviation of each number


from its mean. This example creates a report in which the variance of the
units sold in the subcategories within a category is calculated with the
assumption that the data provided represents the entire population.

Compare this example report to the example for variance of a sample to see
the different values returned when calculating for a population as opposed
to a sample.

The report includes the attributes Category and Subcategory, and the
metrics Units Sold and VarP by Category. A report filter limits the categories
displayed to Books and Movies. The VarP by Category metric is defined as
follows:

VarP([Units Sold]) {Category, ~}

Var (Variance of a Sample)


Variance is a measure of how spread out a set of values is. It is calculated
as the average squared deviation of each number from its mean.

Copyright © 2023 All Rights Reserved 147


Fu n ct io n s Refer en ce

This function calculates the variance based on a sample of a population.


This is a group-value function.

Syntax

Var <Distinct, FactID>(Argument)

Where:

l Argument is an attribute, fact, or metric representing a list of numbers.

l Distinct is a TRUE/FALSE parameter that allows you to calculate using


all values in the list or only the unique values.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Usage Notes

Assume when using this function that arguments constitute a population


sample, as opposed to a entire population.

Example

This example creates a report in which the variance of the units sold in the
subcategories within a category is calculated, with the assumption that the
data provided is a sample.

Compare this example report to the example for variance of a population to


see the different values returned when calculating for a population as
opposed to a sample.

Copyright © 2023 All Rights Reserved 148


Fu n ct io n s Refer en ce

The report includes the attributes Category and Subcategory, and the
metrics Units Sold and Var by Category. A report filter limits the categories
displayed to Books and Movies. The Var by Category metric is defined as
follows:

Var([Units Sold]) {Category, ~}

Date and Time Functions


This section describes the date and time functions. These functions are
supported by the Analytical Engine.

AddDays
AddDays is used to calculate dates that occur N days before or after a given
date. It returns this information in the form of a date or timestamp.

Syntax

AddDays(Date/Time,Offset)

Where:

l Date/Time is the input date or timestamp.

l Offset is an integer number of days to add.

Copyright © 2023 All Rights Reserved 149


Fu n ct io n s Refer en ce

For information on whether your database supports various date and time
functions, see the Appendix A, MicroStrategy and Database Support for
Functions.

Example

AddDays('2020-07-29', 4) = 2020-08-02

AddDays('2020-07-29 02:00:00', 4) = 2020-08-02 02:00:00

AddDays('2020-03-01', -4) = 2020-02-26

The following example can be used to change a TimeDate attribute or metric


to a different time zone. Subtract four hours to change the time zone from
GMT to EST. This does not account for daylight savings time.

AddDays(TimeDate, -4/24)

AddMonths
AddMonths is used to calculate dates that occur N months before or after a
given date. It returns this information in the form of a date or timestamp.

If the new date does not occur in the new month, the last date of the new
month is returned.

Syntax

AddMonths(Date/Time,Offset)

Where:

l Date/Time is the input date or timestamp.

l Offset is an integer number of months to add.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

AddMonths('2004-07-29', 3) = 2004-10-29

Copyright © 2023 All Rights Reserved 150


Fu n ct io n s Refer en ce

AddMonths('2004-07-29 10:00:00', 3) = 2004-10-29 10:00:00

AddMonths('2003-03-31', -1) = 2003-02-28

CurrentDate
Returns the current date as provided by the database timer.

This function does not take input variables.

Syntax

CurrentDate()

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

CurrentDateTime
Returns the current date and time as provided by the database timer.

This function does not take input variables.

Syntax

CurrentDateTime()

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

CurrentTime
Returns the current time as provided by the database timer.

This function does not take input variables.

Syntax

CurrentTime()

Copyright © 2023 All Rights Reserved 151


Fu n ct io n s Refer en ce

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Date
Returns only the date portion of the date-time column. The time is truncated,
not rounded.

Syntax

Date(Date/Time)

Where:

Date/Time is the input date or timestamp.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 2004-07-29; output is the date 2004-07-29.

Input is the date-time 2004-07-29 02:00:00; output is the date 2004-


07-29.

DateDiff
DateDiff is used to calculate the length of time between two dates. A
numeric value is returned.

Syntax

DateDiff<firstWeekDay>(Date1, Date2, Unit)

Where:

l Date1 and Date2 are the inputs used for date or timestamp values. You
can use metrics, constants, attribute forms, or functions that result in a

Copyright © 2023 All Rights Reserved 152


Fu n ct io n s Refer en ce

date or timestamp. For example, you can include CurrentDate() as an


input to compare historical dates from an attribute form to the current date.

l Unit is the unit of time that is to be measured. You can return the length
of time in one of the following units:

Unit of Value in the function


time expression

Seconds "s"

Minutes "mn"

Hours "h"

Days "d"

Weeks "w"

Months "m"

Quarters "q"

Years "y"

l firstWeekDay (default value is 1) is a parameter that can be used if you


are returning the length of time in weeks. This parameter determines
which day of the week is considered as the first day of the week, so that
the difference in weeks can be accurately determined. You can type an
integer value from 1 to 7, with 1 representing Sunday, 2 representing
Monday, and so on until 7 representing Saturday.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

You can use DateDiff to create a metric or attribute form that lists the length
of time between two dates. One common way to do this is to compare the

Copyright © 2023 All Rights Reserved 153


Fu n ct io n s Refer en ce

date information you have stored to the current date. Consider a report or
dossier that includes a Day attribute with a single ID form. You can create a
metric with the following definition:

DateDiff(Day@ID, CurrentDate(), "d")

For each element of the Day attribute, the metric displays the number of
days between that date and the current date when running the report or
dossier.

When using the DateDiff function in MicroStrategy Web, you will need to
replace the Day@ID attribute in the function definition. Create the metric
[MAX(Day@ID)] and define the function as follows: DateDiff([MAX
(Day@ID)], CurrentDate(), "d")

DayofMonth
Returns a number corresponding to the day of the month of the date
provided. The value returned is an integer between 1 and 31.

Syntax

DayofMonth(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 7/11/2002; output is the integer 11.

Input is the date 2003/10/10; output is the integer 10.

Copyright © 2023 All Rights Reserved 154


Fu n ct io n s Refer en ce

DayofWeek
Returns the number of the day in the week corresponding to the input date.
The return value is an integer between 1 and 7. The value of 1 represents
Sunday and the value of 7 represents Saturday.

Syntax

DayofWeek(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 5/16/2003; output is the integer 6, which represents


Friday.

Input is the date 2003/9/9; output is the integer 3, which represents


Tuesday.

DayofYear
Returns the number of the day in the year of the input date. The return value
is an integer between 1 and 365.

Syntax

DayofYear(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Copyright © 2023 All Rights Reserved 155


Fu n ct io n s Refer en ce

Example

Input is the date 1/16/2003; output is the integer 16.

Input is the date 2/17/2003; output is the integer 48.

DaysBetween
Returns the difference in days between two given dates as an integer value.
The calculation of the difference is based on the number of day boundaries
crossed, not the number of twenty-four hours periods elapsed. If the first
date argument is later than the second date argument, the result is a
negative number. The result does not display the time stamps, as they are
truncated before performing the calculation.

Syntax

DaysBetween(Date/Time1, Date/Time2)

Where:

l Date/Time1 is the start date.

l Date/Time2 is the end date.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Examples

Inputs are the dates 2004-07-29 and 2004-07-25; output is the integer -
4.

Inputs are the dates 2004-07-29 02:00:00 and 2004-07-31 01:00:00;


output is the integer 2.

FiscalMonth
Returns the numeric position of a month within a fiscal year, for a given input
date. This function is useful in financial reporting when the start of the fiscal

Copyright © 2023 All Rights Reserved 156


Fu n ct io n s Refer en ce

year is different than the start of the calendar year.

Syntax

FiscalMonth<firstMonth>(Date/Time)

Where:

l Date/Time is the input date or timestamp.

l firstMonth (default value is 1) is a parameter that determines which


month is considered as the start of the fiscal year. You can type an integer
value from 1 to 12, with 1 representing January, 2 representing February,
and so on until 12 representing December.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create a metric with the following definition:

FiscalMonth<firstMonth=4>(Day)

For each element of the Day attribute, the metric displays the numeric
position of the month within the fiscal year for that date. For this example,
since the fiscal year starts in April, a date of July 4, 2014 would return 4.
This is because July is the fourth month in the fiscal year.

FiscalQuarter
Returns the numeric position of a quarter within a fiscal year, for a given
input date. This function is useful in financial reporting when the start of the
fiscal year is different than the start of the calendar year.

Syntax

FiscalQuarter<firstMonth>(Date/Time)

Where:

Copyright © 2023 All Rights Reserved 157


Fu n ct io n s Refer en ce

l Date/Time is the input date or timestamp.

l firstMonth (default value is 1) is a parameter that determines which


month is considered as the start of the fiscal year. You can type an integer
value from 1 to 12, with 1 representing January, 2 representing February,
and so on until 12 representing December.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create a metric with the following definition:

FiscalQuarter<firstMonth=7>(Day)

For each element of the Day attribute, the metric displays the numeric
position of the quarter within the fiscal year for that date. For this example,
since the fiscal year starts in July, a date of October 13, 2014 would return
2. This is because October is in the second quarter of the fiscal year.

FiscalWeek
Returns the numeric position of a week within a fiscal year, for a given input
date. This function is useful in financial reporting when the start of the fiscal
year is different than the start of the calendar year.

Syntax

FiscalWeek<firstWeekDay, firstMonth>(Date/Time)

Where:

l Date/Time is the input date or timestamp.

l firstWeekDay (default value is 1) is a parameter that determines which day of


the week is considered as the first day of the week. You can type an integer value

Copyright © 2023 All Rights Reserved 158


Fu n ct io n s Refer en ce

from 1 to 7, with 1 representing Sunday, 2 representing Monday, and so on until 7


representing Saturday.

l firstMonth (default value is 1) is a parameter that determines which


month is considered as the start of the fiscal year. You can type an integer
value from 1 to 12, with 1 representing January, 2 representing February,
and so on until 12 representing December.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create a metric with the following definition:

FiscalWeek<firstWeekDay=1, firstMonth=7>(Day)

For each element of the Day attribute, the metric displays the numeric
position of the week within the fiscal year for that date. For this example,
since the fiscal year starts in July, a date of July 8, 2014 would return 2. This
is because the first fiscal week runs from July 1 st through July 5 th . Then on
July 6 th , the first Sunday of the fiscal year, the second fiscal week starts.
This week includes July 8 th , and so 2 is returned.

FiscalYear
Returns the fiscal year of the input date. This function is useful in financial
reporting when the start of the fiscal year is different than the start of the
calendar year.

When determining the fiscal year, the year returned is the year in which the
fiscal year ends. For example, if a fiscal year runs from March 1, 2014
through April 30, 2015, the fiscal year is 2015.

Syntax

FiscalYear<firstMonth>(Date/Time)

Copyright © 2023 All Rights Reserved 159


Fu n ct io n s Refer en ce

Where:

l Date/Time is the input date or timestamp.

l firstMonth (default value is 1) is a parameter that determines which


month is considered as the start of the fiscal year. You can type an integer
value from 1 to 12, with 1 representing January, 2 representing February,
and so on until 12 representing December.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create a metric with the following definition:

FiscalYear<firstMonth=2>(Day)

For each element of the Day attribute, the metric displays the fiscal year for
that date. A date of July 4, 2013 would have a fiscal year of 2014.

Hour
Returns the integer value for the hour of the input time. The return value is
an integer between 0 and 23.

Syntax

Hour(Argument)

Where:

Argument is a metric representing a list of dates and times.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Copyright © 2023 All Rights Reserved 160


Fu n ct io n s Refer en ce

Input is the time 9:45 am; output is the integer 9.

Input is the time 11:10 pm; output is the integer 23.

Millisecond
Returns the integer value for the millisecond of the input time.

Syntax

Millisecond(Argument)

Where:

Argument is a metric representing a list of dates and times.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Minute
Returns the integer value for the minute of the input time. The return value is
an integer between 0 and 59.

Syntax

Minute(Argument)

Where:

Argument is a metric representing a list of dates and times.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the time 9:45 am; output is the integer 45.

Input is the time 11:10 pm; output is the integer 10.

Copyright © 2023 All Rights Reserved 161


Fu n ct io n s Refer en ce

Month
Returns the number of the month in the year of the input date. The return
value is an integer between 1 and 12.

Syntax

Month(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 5/16/2003; output is the integer 5.

Input is the date 2003/9/3; output is the integer 9.

MonthEndDate
Returns the date of the last day of the month in which a date or timestamp
occurs.

Syntax

MonthEndDate(Date/Time)

Where:

Date/Time is the input date or timestamp.

For information on whether your database supports various date and time
functions,see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 2004-07-29; output is the date 2004-07-31.

Copyright © 2023 All Rights Reserved 162


Fu n ct io n s Refer en ce

MonthStartDate
Returns the date of the first day of the month in which a date or timestamp
occurs.

Syntax

MonthStartDate(Date/Time)

Where:

Date/Time is the input date or timestamp.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 2004-07-29; output is the date 2004-07-01.

MonthsBetween
Returns the difference in months between two dates as an integer value.
The difference is calculated by the number of months elapsed and not by the
number of month boundaries crossed. If the first date argument is later than
the second date argument, the result is a negative number. The result does
not display the timestamps, as they are truncated before performing the
calculation.

Syntax

MonthsBetween(Date/Time1, Date/Time2)

Where:

l Date/Time1 is the start date.

l Date/Time2 is the end date.

Copyright © 2023 All Rights Reserved 163


Fu n ct io n s Refer en ce

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Inputs are the dates 2004-07-29 and 2004-02-28; output is the integer -5.

Inputs are the dates 2004-07-29 and 2004-09-29; output is the integer 2.

Quarter
Returns the number of the quarter in the year of the input date. The return
value is an integer between 1 and 4.

Syntax

Quarter(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 5/16/2003; output is the integer 2.

Input is the date 2003/9/3; output is the integer 3.

QuarterStartDate
Returns the date of the first day of the quarter in which a date or timestamp
occurs.

Syntax

QuarterStartDate<firstMonth>(Date/Time)

Where:

Copyright © 2023 All Rights Reserved 164


Fu n ct io n s Refer en ce

l Date/Time is the input date or timestamp.

l firstMonth (default value is 1) is a parameter that determines which


months are considered as the first months of each quarter. You can type
an integer value from 1 to 12, with 1 representing January, 2 representing
February, and so on until 12 representing December. Defining one month
automatically defines the first month for the other quarters as well. For
example, if you specify January as the first month, April, July, and October
are also considered as the first month of quarters.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create an attribute form with the following definition:

QuarterStartDate<firstMonth=1>(Day)

For each element of the Day attribute, the new attribute form displays the
start date of the quarter.

Second
Returns the integer value for the second of the input time. The return value
is an integer between 0 and 59.

Syntax

Second(Argument)

Where:

Argument is a metric representing a list of dates and times.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Copyright © 2023 All Rights Reserved 165


Fu n ct io n s Refer en ce

Example

Input is the time 9:45:13 am; output is the integer 13.

Input is the time 11:10:47 pm; output is the integer 47.

ToDateTime (Convert String or Number to a Date or


Timestamp)
The ToDateTime function converts a string of characters or a number into a
date or timestamp.

Syntax

ToDateTime<Pattern=null>(Argument)

Where:

l Argument is a fact, metric, column, or constant value that provides the


strings that are converted to numeric values.

l Pattern is a parameter that determines the date or timestamp format


used for the resulting date or timestamp. By default, dates are expected to
be of the format MM/dd/yyyy. When providing a pattern, enclose the
pattern in double quotes (""). For example:

ToDateTime<pattern="MM/dd/yyyy">(Day@ID)

To specify a pattern, you can use custom formatting symbols that conform
to the standards of the International Components for Unicode. For
information about the custom formatting standards and syntax, see
Formatting Dates and Times in the ICU Documentation.

Example

ToDateTime<pattern="MM/dd/yyyy">(Day@ID)

This example would return the data stored for the ID form of Day in a date
format that includes month, day, and year information.

Copyright © 2023 All Rights Reserved 166


Fu n ct io n s Refer en ce

Week
Returns the number of the week in the year of the input date. The return
value is an integer between 1 and 54.

Syntax

Week(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 5/16/2003; output is the integer 20.

Input is the date 2003/9/9; output is the integer 37.

WeekStartDate
Returns the date of the first day of the week in which a date or timestamp
occurs.

Syntax

WeekStartDate<firstDay>(Date/Time)

Where:

l Date/Time is the input date or timestamp.

l firstDay (default value is 1) is a parameter that determines which day of


the week is considered as the first day of the week. You can type an
integer value from 1 to 7, with 1 representing Sunday, 2 representing
Monday, and so on until 7 representing Saturday.

Copyright © 2023 All Rights Reserved 167


Fu n ct io n s Refer en ce

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Consider a report or dossier that includes a Day attribute with a single ID


form. You can create an attribute form with the following definition:

WeekStartDate<firstDay=1>(Day)

For each element of the Day attribute, the new attribute form displays the
start date of the week.

Year
Returns the year of the input date. The return value is an integer between
1900 and 9999.

Syntax

Year(Argument)

Where:

Argument is a metric representing a list of dates.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 5/16/2003; output is the integer 2003.

Input is the date 2002/9/9; output is the integer 2002.

YearEndDate
Returns the date of the last day of the year in which a date or timestamp
occurs.

Syntax

Copyright © 2023 All Rights Reserved 168


Fu n ct io n s Refer en ce

YearEndDate(Date/Time)

Where:

Date/Time is the input date or timestamp.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Example

Input is the date 2004-07-29; output is the date 2004-12-31.

YearStartDate
Returns the date of the first day of the year in which a date or timestamp
occurs.

Syntax

YearStartDate(Date/Time)

Where:

Date/Time is the input date or timestamp.

For information on whether your database supports various date and time
functions, see Appendix A, MicroStrategy and Database Support for
Functions.

Examples

Input is the date 2004-07-29; output is the date 2004-01-01.

Internal Functions
The following are internal function types:

Copyright © 2023 All Rights Reserved 169


Fu n ct io n s Refer en ce

l MicroStrategy Apply, or Pass-through, functions provide access to


functionality that is not standard in MicroStrategy but is available in many
Relational Database Management Systems (RDBMS). These
MicroStrategy functions act as containers for non-standard SQL
expressions passed to your warehouse database. The MicroStrategy
Apply functions are listed below:

l ApplyAgg defines simple metrics or facts using group-value aggregation


functions.

l ApplyLogicdefines custom filters using comparison operators.

l ApplyLogic defines custom filters using logical operators.

l ApplyOLAP defines compound functions using database-specific OLAP


functions such as Rank and RunningSlope.

l ApplySimple uses simple operators and functions like +, -, and * to


perform single-value operations at the database level.

l Banding functions are used to differentiate displayed data on a report.


You can divide data into bands in the following ways:

l Banding distributes the values into bands of equal size.

l BandingC (Banding Count) distributes values into a specified number of


bands.

l BandingP (Banding Points) distributes values into bands based on


specific intervals of values.

l Case functions return specified data based on the evaluation of user-


defined conditions.

l Case evaluates multiple expressions until a condition is determined to


be true, then returns a corresponding value.

l CaseV (Case Vector) evaluates a single metric and returns different

Copyright © 2023 All Rights Reserved 170


Fu n ct io n s Refer en ce

values according to the results.

l Coalesce returns the value of the first non-null argument.

Apply (Pass-Through) Functions


MicroStrategy Apply functions provide access to functions or syntactic
constructs that are not standard in MicroStrategy but are provided by
various Relational Database Management System (RDBMS) platforms.

MicroStrategy strongly advises against using Apply functions when


standard MicroStrategy functions can be used to achieve the same goal,
because using RDBMS functions effectively bypasses the validations and
other benefits of MicroStrategy products. Using Apply functions is
recommended only when corresponding functionality does not exist in
MicroStrategy. When you need to use an Apply function, MicroStrategy
encourages you to submit an enhancement request for inclusion of the
desired feature in a future product release.

To use Apply functions, you must have the Use FreeForm SQL Editor
privilege.

Syntax Common to Apply Functions


While each Apply function has its own syntax, the Apply functions share
several syntactic features:

l The "#n" code in Apply function syntax serves as placeholders for the
MicroStrategy objects being passed to your database. The index for
referencing these objects begins with 0 and increases by 1 for each
successive object passed.

For example, ApplySimple("#0 * #1",[col1],[col2]) indicates


that two items, col1 and col2, referenced as #0 and #1, respectively,
are being passed to your database to be multiplied together (by the
database). If the number of references in an Apply function (for example,

Copyright © 2023 All Rights Reserved 171


Fu n ct io n s Refer en ce

#0, #1, and so forth) exceeds the number of objects passed in that
function, MicroStrategy passes the last available object in place of the
extra reference(s).

For example, ApplySimple("#0 * #1 * #2 * #3",[col1],


[col2]) uses two more references than there are arguments to pass, so
MicroStrategy passes #2 and #3, the extra references, as col2, the last
available object in the list.

l To use # as a character rather than a placeholder, use four # characters in


a row. See the syntax below for an example.

ApplyComparison(UPPER(#0) like
'Z####%', Country@DESC)

The SQL for the function is:

Select a.11[COUNTRY_ID] AS COUNTRY_ID


from [LU_COUNTRY] a11
where upper(a11.[COUNTRY_NAME])
like 'Z#%'

l Do not use form groups for the attribute form expression when using Apply
functions, because form groups are ignored by the Analytical Engine.
Instead, use a single form. For example, instead of using
Customer@Name, where Name is defined to contain Customer's first
name, middle name, and last name, use ID or any other single form.

For more general information on Apply functions as well as an example, see


Apply (Pass-Through) Functions, page 17.

ApplyAgg
The ApplyAgg function is used to define simple metrics or facts by using
database-specific, group-value functions. The ApplyAgg function itself is a
group-value function and accepts facts, attributes, and metrics as input.

Copyright © 2023 All Rights Reserved 172


Fu n ct io n s Refer en ce

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

ApplyAgg()

Accepts facts, attributes, and metrics as input.

All placeholders must begin with #0 and increase in increments of 1.

Example

ApplyAgg("Regrsxx(#0,#1)", [Argument 1], [Argument 2] {~+}

ApplyComparison
ApplyComparison is used to define a filter by populating the WHERE clause
in the SQL passed to your RDBMS, and can take facts, attributes, and
metrics as input.

The ApplyComparison function is used with RDBMS comparison operators


such as >, like, and In.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

ApplyComparison()

Example

ApplyComparison ("#0>#1", Store@ID,2)

For another example of the ApplyComparison function, see Example:


ApplyComparison Used to Check a Prompted Date, page 19.

Copyright © 2023 All Rights Reserved 173


Fu n ct io n s Refer en ce

ApplyLogic
The ApplyLogic function is used to define custom filters. It is used with
logical operators such as AND and OR. ApplyLogic is a logical function.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

ApplyLogic()

Accepts logic (Boolean) values as input.

Example

ApplyLogic("#0 and #1", Year@ID>2003, Month@ID>200301)

ApplyOLAP
OLAP functions are group-value functions that take a set of data as input
and generate a set of data as output, usually reordering the set according to
some criteria.

ApplyOLAP is the MicroStrategy Apply function tool used for OLAP


functionality when you wish to use the native capabilities of your RDBMS. It
is used to define compound metrics via database-specific functions such as
Rank(). ApplyOLAP, like ApplySimple, is used to define metrics but
differs in that it only accepts metrics as input.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

ApplyOLAP()

Accepts only metrics as input.

Example

Copyright © 2023 All Rights Reserved 174


Fu n ct io n s Refer en ce

ApplyOLAP("RunningSlope(#0,#1)", [Metric 1], [Metric 2])

ApplySimple
The ApplySimple function is a single-value function. It is used to insert any
single-value, database-specific functions and simple operators directly into
SQL.

In general, ApplySimple can be used to create the following objects:

l Attribute form

For any Apply function, the attribute form in the arguments should be a
single form—not a form group. The engine ignores any definitions based
on attribute forms.

l Consolidation

l Custom group

l Fact

l Metric

l Subtotal

l Transformation

For information about consolidations, custom groups, metrics, and


subtotals, see the Advanced Reporting Help.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

ApplySimple()

Accepts facts, attributes, and metrics as input.

Examples of Object Creation

Copyright © 2023 All Rights Reserved 175


Fu n ct io n s Refer en ce

Expression
Examples
type

ApplySimple("Datediff(YY,#0,getdate())", [BIRTH_DATE]), in which


[BIRTH_DATE] is an attribute
Attribute
ApplySimple("Months_between(sysdate,#0)",[CURRENT_DT]), in which
[CURRENT_DT] is an attribute

ApplySimple("Greatest(#0,#1,#2)", Metric_1, Metric_2,Metric_3)

Compound ApplySimple(" CASE WHEN #0 between 0 and 100000 THEN 'Low' WHEN
Metric #0 between 100001 and 200000 THEN 'Med' ELSE 'High' END ", Sum
(Revenue){~})

Examples in Custom Expressions

l ApplySimple("Datediff(YY,#0,getdate())", [BIRTH_DATE])

l ApplySimple("Months_between(sysdate,#0)", [CURRENT_DT])

Examples: Incorrect Usage

l ApplySimple("Sum(#0)",[Column 1])

l ApplySimple("Count(#0)",[Column 2])

The two examples immediately above are incorrect and should not be used
in your application because of the following two reasons:

l ApplySimple is a single-value function and therefore can only be used with


single-value functions. Sum and Count are both group-value functions and
therefore should not be used with ApplySimple.

l Sum and Count are both MicroStrategy functions and are not database-
specific; therefore, they should not be used with ApplySimple or any other
Apply functions.

Copyright © 2023 All Rights Reserved 176


Fu n ct io n s Refer en ce

Banding Functions
Banding functions are used to group data on a report so that it is both more
comprehensible and aesthetically pleasing than when it is displayed as one
contiguous list. MicroStrategy provides different banding options for you to
use, depending on how you want to divide your data. The banding functions,
their syntaxes, and examples are listed below.

For information on banding functions in custom groups, see the Advanced


Reporting Help.

Banding
This function maps metric values that fall within a certain range to a
particular integer band value. The range and band values are determined by
the parameter input to the function. For example, if 5,000 is the specified
range, the dollar sales are shown in bands of 0 - 5,000, 5,001 - 10,000,
10,001 - 15,000, and so on. Banding is a single-value function.

Syntax

Banding <HasResidue>(Argument, StartAt, StopAt, Size)

Where:

l Argument is a metric.

l StartAt and StopAt are real numbers specifying the full range of the
values to be placed in bands.

l Size is a real number indicating the width of each band.

l HasResidue is a TRUE/FALSE parameter that defines whether an extra


band is created for all values that do not fall within the StartAt and
StopAt values. Defining HasResidue as TRUE allows the function to
create an additional band which is used to identify all values outside of the
defined band range.

Usage Notes

Copyright © 2023 All Rights Reserved 177


Fu n ct io n s Refer en ce

Values in the list that fall outside of the start and end values set in the
function syntax are assigned a band of 0 (zero) in the report interface.

Example

The following example shows how the Banding function acts on report data.
In this case the total revenue for each city is used to divide the report data
into bands:

l The highest total revenue is 405,367 (New York).

l The lowest revenue is 668 (Cleveland).

The metric function syntax is as follows:

Banding([Total Revenue], 1, 410000, 20000)

l Total Revenue is the metric, defined as Sum(Revenue), representing the


list of values acted on by the Banding function.

l 1 is the value at which banding begins.

l 410,000 is the value at which banding ends.

l 20,000 is the size of the range of values included in each band.

Only part of the resulting report is displayed here.

The result is that 21 bands are created, each encompassing a range of


20,000 dollars of total revenue. To determine the number of bands, 410,000
is divided by 20,000 resulting in 20.5 (rounded to nearest integer, 21). Each
band is given an integer value of between 1 and 21.

Copyright © 2023 All Rights Reserved 178


Fu n ct io n s Refer en ce

BandingC (Banding Count)


BandingC returns metric data grouped into a specified number of bands and
assigns integer values to the resulting bands (for example, a total of 25,000
in dollar sales shown in five equal bands). This is a single-value function.

Syntax

BandingC <HasResidue>(Argument, StartAt, StopAt, BandCount)

Where:

l Argument is a metric.

l BandCount is a positive integer indicating the number of bands into which


the total is divided.

Copyright © 2023 All Rights Reserved 179


Fu n ct io n s Refer en ce

l StartAt and StopAt are real numbers specifying the full range of the
values to be placed in bands.

l HasResidue is a TRUE/FALSE parameter that defines whether an extra


band is created for all values that do not fall within the StartAt and
StopAt values. Defining HasResidue as True allows the function to
create an additional band which is used to identify all values outside of the
defined band range.

Usage Notes

Values that fall outside of the range indicated by the Start and Stop values
are assigned a band of 0 (zero).

Example

The following example shows how the BandingC function acts on report
data. This example uses the same set of values as the example for the
Banding function. Using the BandingC function, you can designate the
number of bands created for the range of values.

The metric function syntax is as follows:

BandingC([Total Revenue], 1, 410000, 25)

Where:

l Total Revenue is the metric, defined as Sum(Revenue), representing the


list of values acted on by the BandingC function.

l 1 is the value at which banding begins.

l 410,000 is the value at which banding ends.

l 25 is the number of bands into which you want the values divided.

Only part of the resulting report is displayed here.

The result is that 20 bands of equal sizes are created. To determine the
range of each band, 410,000 is divided by 25 resulting in bands of 16,400.
Each band is given an integer value of between 1 and 25.

Copyright © 2023 All Rights Reserved 180


Fu n ct io n s Refer en ce

BandingP (Banding Points)


Returns metric data grouped into bands identified by user-specified
boundary point values (for example, 0 - 5,000, 5,000 - 20,000, 20,000 -
30,000). This function assigns integer values to the resulting metric and
allows you to create band intervals of varying widths. This is a single-value
function.

Syntax

BandingP <HasResidue>(Argument, Boundary1, Boundary2,...,


BoundaryN)

Where:

Copyright © 2023 All Rights Reserved 181


Fu n ct io n s Refer en ce

l Argument is a metric.

l Boundary1 through BoundaryN are real numbers indicating the cut-off


value for each band. Boundary1 is less than Boundary2, Boundary2 is
less than Boundary3, and so on.

l HasResidue is a TRUE/FALSE parameter that defines whether an extra


band is created for all values that do not fall within the Boundary1 and
BoundaryN values. Defining HasResidue as TRUE allows the function to
create an additional band which is used to identify all values outside of the
defined band range.

Example

The following example shows how the BandingP function acts on report
data. This example again uses the same data set as in the previous
examples (Banding and BandingC). Using the BandingP function, you can
designate the boundaries for each interval.

The metric function syntax is as follows:

BandingP([Total Revenue],
1,20000,40000,60000,80000,100000,410000)

Where:

l Total Revenue is the metric, defined as Sum(Revenue), representing the


list of values acted on by the BandingP function.

l All other values specify the boundaries of an interval. There are six
intervals defined as follows:

l Band 1: 1 £ [Total Revenue] < 20000

l Band 2: 20,000 £ [Total Revenue] < 40,000

l Band 3: 40,000 £ [Total Revenue] < 60,000

l Band 4: 60,000 £ [Total Revenue] < 80,000

Copyright © 2023 All Rights Reserved 182


Fu n ct io n s Refer en ce

l Band 5: 80,000 £ [Total Revenue] < 100,000

l Band 6: 100,000 £ [Total Revenue] £ 410,000

Only part of the resulting report is displayed here.

Case Functions
Case functions return specified data in a SQL query based on the evaluation
of user-defined conditions. In general, a user specifies a list of conditions
and corresponding return values. When MicroStrategy queries the data
warehouse, the software determines which condition evaluates as true and
then returns the value that the user has specified that corresponds to that
condition. The case functions, their syntaxes, and examples are listed
below.

Copyright © 2023 All Rights Reserved 183


Fu n ct io n s Refer en ce

Case
This function evaluates multiple expressions until a condition is determined
to be true, then returns a corresponding value. If all conditions are false, a
default value is returned. Case can be used for categorizing data based on
multiple conditions. This is a single-value function.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

Case (Condition1, ReturnValue1, Condition2,ReturnValue2,...,


DefaultValue)

Where:

l Condition1 is the first condition to evaluate. The condition can contain


metrics, comparison and logical operators, and constants.

l ReturnValue1 is a constant or metric value to return if the Condition1


condition is TRUE.

l Condition2 is the second condition to evaluate. The condition can


contain metrics, comparison and logical operators, and constants.

l ReturnValue2 is a constant or metric value to return if the Condition2


condition is TRUE.

l ... represents any number of Conditions and Return Values that can be
passed through this function.

l DefaultValue is the information to return if none of the other conditions


are TRUE.

Example

This example generates a report where if the revenue, represented by the


Total Revenue metric, is less than 300,000, the function returns a 0; if the

Copyright © 2023 All Rights Reserved 184


Fu n ct io n s Refer en ce

revenue is less than 600,000, the function returns a 1; if revenue is any


other value, the function returns a 2. The case metric is defined as follows:

Case(([Total Revenue] < 300000), 0, ([Total Revenue] < 600000),


1, 2)

Difference Between Case and If

The If function is very similar to the Case function. Each function takes a
condition as an argument and returns a value depending on whether the
condition is true or not. The Case function can evaluate multiple conditional
arguments, while the If function can only evaluate one condition. However,
the If function can be evaluated by either the SQL Engine or the Analytical
Engine, while the Case function is evaluated only by the Analytical Engine.

CaseV (Case Vector)


CaseV evaluates a single metric and returns different values according to
the results. It can be used to perform transformations on a metric. For
example, if provided a list of values ranging from 1 to 12, CaseV might return
January for a value of 1, February for a value of 2, etc. This is a single-value
function.

Copyright © 2023 All Rights Reserved 185


Fu n ct io n s Refer en ce

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

CaseV (Argument, Value1, Result1, Value2, Result2, ...,


DefaultResult)

Where:

l Argument is the metric against which all values are compared.

l Value1 is the first value (constant or metric) to be evaluated.

l Result1 is the information to return (constant or metric) if the Value1


value is equal to the value for the Metric.

l Value2 is the second value (constant or metric) to be evaluated.

l Result2 is the information to return (constant or metric) if the Value2


value is equal to the value for the Metric.

l ... represents any number of Conditions and Return Values that can be
passed through this function.

l DefaultResult is the information to return (constant or metric) if none of


the other values are Equal to the Metric.

Usage Notes

The metric or argument in the CaseV expression is always held as a float.


This means that even if the value is 2, it is held as 2.00000; and therefore 2
and 2.00000 are never considered equal. For this reason, it is best if you
wrap the metric or argument in the integer function, for example, CaseV(int
(M1), 2, A,...).

Example

This simple example generates a report where if the Unit Profit for the item
is 2, the function returns a 200; if the Unit Profit for the item is 3, the
function returns a 300; if Unit Profit is any other value, the function returns a

Copyright © 2023 All Rights Reserved 186


Fu n ct io n s Refer en ce

1000000. Notice how a single metric, Unit Profit, is evaluated against


multiple numeric values. The report contains the attribute Item and the
metrics Unit Profit and CaseV. A report filter limits the items displayed to
those in the subcategory Action. The CaseV metric is defined as follows:

CaseV ([Unit Profit], 2, 200, 3, 300, 1000000)

Coalesce
Returns the value of the first non-null argument. Coalesce can be used to
identify data in tables that may not be fully populated or in metric definitions.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

Coalesce (Argument1, Argument2,..., ArgumentN)

Where:

The arguments for the Coalesce function can be any expression that can be
evaluated as null or not null.

Copyright © 2023 All Rights Reserved 187


Fu n ct io n s Refer en ce

Usage Notes

You can use the Coalesce function in defining a metric, but more often it is
used with the Query Builder feature to support the inclusion of the Coalesce
function in SQL queries. See the example below for more detailed
information.

Example

Your database has two tables T1 and T2 that include the column MONTH_ID
with the format yyyymm. You want to filter on a specific month, but you are
not sure which table has been populated with month data. In the Query
Builder Editor, you can filter your SQL query by creating the condition
Coalesce(T1.MONTH_ID, T2.MONTH_ID) = 200410. The WHERE
clause of the SQL query checks for the first non-null MONTH_ID column and
compares it to the value 200410.

For more information on Query Builder, see the Advanced Reporting Help.

NULL/Zero Functions
The NULL/Zero functions are often used to determine how NULLs and zeros
are displayed on a report. They can also be used as a form of data validation
to ensure meaningful results. For example, an otherwise invalid
mathematical expression such as 5 + NULL can be changed to 5 + 0.

IsNotNull
Returns TRUE if value input is not NULL; otherwise, returns FALSE. This is a
comparison function.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

IsNotNull(Argument)

Copyright © 2023 All Rights Reserved 188


Fu n ct io n s Refer en ce

Where:

Argument is a fact or metric.

Usage Notes

The IsNull and IsNotNull functions work only with the data returned from the
database. For example, if the database data is NULL, the IsNotNull function
returns a FALSE. However, you may see NULL data when you manipulate a
report after its original generation and that manipulation does not
regenerate the data from the database. This can happen when you page by,
for example, and the result includes a NULL.

IsNull
Returns TRUE if the value is NULL; otherwise, returns FALSE. This is a
comparison function.

Depending on your MicroStrategy product and licensing, this function may


not be available.

Syntax

IsNull(Argument)

Where:

Argument is a fact or metric.

Usage Notes

The IsNull and IsNotNull functions work only with the data returned from the
database. For example, if the database data is NULL, the IsNotNull function
returns a FALSE. However, you may see NULL data when you manipulate a
report after its original generation and that manipulation does not
regenerate the data from the database. This can happen when you page by,
for example, and the result includes a NULL.

Copyright © 2023 All Rights Reserved 189


Fu n ct io n s Refer en ce

NullToEmpty
Converts a value of NULL to an empty string. If the value is not NULL, the
original value is kept.

Syntax

NullToEmpty(Argument)

Where:

Argument is metric or attribute form.

Example

You can use NullToEmpty when creating derived attributes to convert


NULL values for attribute elements to empty strings. For example, you can
convert NULL values to empty strings so that attribute element values can be
successfully concatenated with functions such as Concat (see Concat
(Concatenate), page 295) or ConcatBlank (see ConcatBlank (Concatenate
Plus Blank Space), page 297).

For steps to create derived attributes, see the MicroStrategy Web Help.

NullToZero
Converts a value of NULL to 0. If the value is not NULL, the original value is
kept.

Syntax

NullToZero(Argument)

Where:

Argument is a fact or metric.

Example

In this simple example, the function NullToZero is applied to a list of values


(12, NULL, 97, 43, NULL). The resulting list is (12, 0, 97, 43, 0). This
function could be applied to a value list before it is acted on by another

Copyright © 2023 All Rights Reserved 190


Fu n ct io n s Refer en ce

function such as Average so that NULL values in a list are included as list
elements and factored into the average as zeros.

ZeroToNull
Converts a value of 0 to NULL. If the value is not 0, the original value is kept.

Syntax

ZeroToNull(Argument)

Where

Argument is a fact or metric.

Example

In this simple example, the function ZeroToNull is applied to a list of values


(12, 0, 97, 43, 0). The resulting list is (12, NULL, 97, 43, NULL). This
function could be applied to a value list before it is acted on by another
function such as Average so that zero values in a list are not included as list
elements and therefore not factored into the average.

OLAP Functions
OLAP functions are also known as relative functions. They take multiple
elements from a list and return a new list of elements. The following applies
to all OLAP functions:

l SortBy is applied before the engine performs the calculation of an OLAP


function.

l In OLAP functions, the SortBy parameter can be either a metric or an


attribute.

Many OLAP functions calculate measures useful for analyzing a set of


values such as the sum, average, and standard deviation. These functions
fall into three groups depending on how they select the window of values on
which they base their calculations. These groups are as follows:

Copyright © 2023 All Rights Reserved 191


Fu n ct io n s Refer en ce

l Running: Functions with a running window include the current value and
all preceding values. For example, given the list (1, 2, 3, 4), RunningSum
returns the sums 1, 3, 6, and 10. This example is illustrated in the table
below. These functions include the word Running in their name, such as
RunningAvg and RunningStDev.

l Moving: Functions with a moving window include the current value and a
fixed number of preceding values. For example, given the list (1,2,3,4) and
a window size of 2, MovingSum returns 1, 3, 5, and 7. This example is
illustrated in the table below. These functions include the word Moving in
their name, such as MovingAvg and MovingStDev.

l OLAP: Functions with flexible windows allow you to set where windows
begin and end in relation to the current value. This feature allows you to
include both preceding and succeeding values in your calculations. For
example, you can use OLAPSum to include one value above and below the
current row. This example is illustrated in the table below. These functions
include the word OLAP, such as OLAPSum and OLAPAvg.

The following table lists a comparison of the example scenarios described


above.

Values RunningSum MovingSum OLAPSum

1 1 (1) 1 (1) 3 (1+2)

2 3 (1+2) 3 (1+2) 6 (1+2+3)

3 6 (1+2+3) 5 (2+3) 9 (2+3+4)

4 10 (1+2+3+4) 7 (3+4) 7 (3+4)

ExpWghMovingAvg (Exponential Weighted Moving Average)


ExpWghMovingAvg allows you to place more or less emphasis on recent
data than on past data within a specified number of rows. It is calculated

Copyright © 2023 All Rights Reserved 192


Fu n ct io n s Refer en ce

within the specified window size and can restart based on an attribute
specified in the function parameters.

Syntax

ExpWghMovingAvg <BreakBy, SortBy> (Argument, WindowSize, Rate)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize indicates the number of values to use in each calculation.

l Rate is a positive real number specifying the base weight applied to each
argument value. In the calculation, exponents are sequentially applied to
the rate value. Assign a rate of less than one to give more emphasis to
more recent data; assign a rate of greater than 1 to give greater emphasis
to past data.

Expression

Where:

l k = row number

l y i = metric value at the ith row

l m = window size or the row number, whichever is smaller

Copyright © 2023 All Rights Reserved 193


Fu n ct io n s Refer en ce

l n = number of rows

l w = the base weight applied to each value, which is determined by the


Rate value in the function, as described in the function syntax details
above

Rows with null values are excluded from the calculation.

Example

This example uses small numbers to demonstrate the calculation for the
exponential weighted moving average (ExpWghMovingAvg) function. For
example, you have a list of values (32, 8, 5), with 5 being the most recent
value, and you assign a rate of .5 and a window size of 2.

EWM
Values Calculation
average

32(.5) 0 / (.5) 0 = 32(1)/1 = 32


32 32

8(.5) 0 + 32(.5) 1 / (.5) 0 + (.5) 1 =


8 16
8(1)+ 32(.5) / 1+.5 = 8+16 / 1.5 = 16

5(.5) 0 + 8(.5) 1 / (.5) 0 + (.5) 1 =


5 6
5(1)+ 8(.5) / 1+.5 = 5+4 / 1.5 = 6

As an additional example, the Human Resources Analysis Module project


includes the Division Breakdown report shown below.

Copyright © 2023 All Rights Reserved 194


Fu n ct io n s Refer en ce

A description of how the MovingAvg metric is used on the report is provided


in MovingAvg (Moving Average), page 209. You can also add an exponential
weighted moving average metric to this report to apply more or less
emphasis to older data. For example, you can create another derived metric
named ExpWghMovingAvg with the following expression:

ExpWghMovingAvg<BreakBy={Division}, SortBy=(Quarter)> (Employees,


4.0, 0.5)

The rate of 0.5 changes the moving average to apply more significance, or
weight, to more recent data. This means that the number of Sales employees
during the first quarter (13) has less weight than the number of Sales
employees in the fourth quarter (18). When comparing MovingAvg and
ExpWghMovingAvg for the Sales division, you can see that the
ExpWghMovingAvg is larger. This is because more significance is given to
more recent data, and the recent trend is that employment is on the rise.
This is shown in the report below.

Copyright © 2023 All Rights Reserved 195


Fu n ct io n s Refer en ce

Conversely, you can modify the same ExpWghMovingAvg metric to use the
following expression:

ExpWghMovingAvg<BreakBy={Division}, SortBy= (Quarter) >


(Employees, 4.0, 2)

The rate of 2 changes the moving average to apply more significance, or


weight, to older data. This means that the number of Sales employees
during the first quarter (13) has more weight than the number of Sales
employees in the fourth quarter (18). When comparing MovingAvg and
ExpWghMovingAvg for the Sales division, you can see that the
ExpWghMovingAvg is smaller. This is because more significance is given to
older data, and employment was lower earlier in the year. This is shown in
the report below.

Copyright © 2023 All Rights Reserved 196


Fu n ct io n s Refer en ce

ExpWghRunningAvg (Exponential Weighted Running


Average)
ExpWghRunningAvg allows you compute a running average while placing
more or less emphasis on recent data than on past data. The calculation can
restart based on an attribute specified in the function parameters.

Syntax

ExpWghRunningAvg <BreakBy, SortBy> (Argument, Rate)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l Rate is a positive real number specifying the base weight applied to each
argument value. In the calculation, exponents are sequentially applied to
the rate value. Assign a rate of less than one to give more emphasis to
more recent data; assign a rate of greater than 1 to give greater emphasis
to past data.

Expression

Copyright © 2023 All Rights Reserved 197


Fu n ct io n s Refer en ce

Where:

l k = row number

l y i = metric value at the ith row

l m = window size or the row number, whichever is smaller

l n = number of rows

l w = the base weight applied to each value, which is determined by the


Rate value in the function, as described in the function syntax details
above

Rows with null values are excluded from the calculation.

Example

This example uses small numbers to demonstrate the calculation for the
exponential weighted running average (ExpWghRunningAvg) function. For
example, you have a list of values (32, 8, 5), with 5 being the most recent
value, and you assign a rate of .5.

EWR
values calculation
average

32(.5) 0 / (.5) 0 = 32(1)/1 = 32


32 32

Copyright © 2023 All Rights Reserved 198


Fu n ct io n s Refer en ce

EWR
values calculation
average

8(.5) 0 + 32(.5) 1 / (.5) 0 + (.5) 1 =


8 16
8(1)+ 32(.5) / 1+.5 = 8+16 / 1.5 = 16

5(.5) 0 + 8(.5) 1 + 32(.5) 2 / (.5) 0 + (.5) 1 +


5 10 (.5) 2 = 5(1)+ 8(.5)+ 32(.25) / 1+ .5 + .25 =

5 + 4 + 8 / 1.75 = 10 (rounded from 9.71)

FirstInRange
Returns the first value in a range of values. FirstInRange can be used to
examine data such as inventory at the beginning of each month.

Calculations can be restarted based on attributes set in the function


parameters. This restart capability differentiates FirstInRange from
First. While First is a group-value function and takes both facts and
metrics as argument input, FirstInRange is an OLAP function and takes
only metrics as argument input.

Syntax

FirstInRange <BreakBy, SortBy> (Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

Expression

Where:

Copyright © 2023 All Rights Reserved 199


Fu n ct io n s Refer en ce

l k = row number

l y 1 = first non-NULL value of the metric after applying the BreakBy and
SortBy parameters

Example

This example shows the results of using the FirstInRange function. The
report includes the attributes Customer Region and Customer State and the
metrics Profit and FirstInRange. A report filter limits the regions displayed to
Northwest, Southeast, and Southwest. The FirstInRange metric is defined as
follows:

FirstInRange<BreakBy={[Customer Region]}, SortBy= ([Customer


State]) >(Profit)

In the following report, FirstInRange returns the first profit value in the list of
Customer States for each Customer Region.

Lag
The Lag function is useful to display a set of metric values in an order
determined by another metric or attribute on the report. This allows you to
compare metric values side-by-side. The easiest way to understand the Lag
function is with an example, provided below.

Copyright © 2023 All Rights Reserved 200


Fu n ct io n s Refer en ce

Syntax

Lag <BreakBy, SortBy> (Argument, Offset, DefaultValue)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is an attribute or metric representing a list of values. It is


common to use a metric for Argument.

l Offset specifies the offset from the current row to display information for.
This offset trails behind the current row (you can use the Lead function to
use an offset that precedes ahead of the current row, see Lead, page 207).
For example, with an offset of two, row three displays data for the row two
behind it, which would be row one.

l DefaultValue is the value displayed for any entries that do not have any
data due to the offset. For example, when using an offset of 2, the first two
entries use the default value.

Some common default values to display include:

l 0: To display a value of 0 for any entries that do not have any data due
to the offset, type 0.

l No data: To display no data for any entries that do not have any data due
to the offset, type ZeroToNull(0).

Example

On a report with Item, Cost, and Profit, you can use the Lag function to
create a Cost (Lag on Profit) metric. This metric displays Cost values based
on the descending sort order of the Profit metric, and is defined with the
following expression:

Lag<SortBy= (Profit Desc) >(Cost, 3.0, 0.0)

Copyright © 2023 All Rights Reserved 201


Fu n ct io n s Refer en ce

Notice that the offset is set to three, meaning that the display of cost values
lags behind by three entries. This is displayed in the report results shown
below.

Only the top and the bottom of the report is shown. To view the entire report
results, you can create this report in the MicroStrategy Tutorial project.

The Cost (Lag on Profit) values are displayed three behind the Cost metric,
and are displayed based on the descending sort order of Profit. Notice that
with an offset of three, the first three entries for Cost (Lag on Profit) use the
default value of zero. Also, the last three values of Cost are not included in
the Cost (Lag on Profit) metric.

The report has been sorted based on the Profit metric to make the Cost (Lag
on Profit) values easier to analyze.

Copyright © 2023 All Rights Reserved 202


Fu n ct io n s Refer en ce

Transformation-Style Analysis Using the Lag and Lead Functions


Transformation-style analysis can be supported using the Lag and Lead
functions provided with MicroStrategy. These functions can be used to
define metrics that compare values from different time periods without the
use of transformations. For information on creating transformations, see the
Project Design Guide.

l The examples shown below were created in the MicroStrategy Tutorial


project.

l The examples below use the Lag function. The Lead function can be used
in the same way. The difference in using Lead rather than Lag is that the
Lead function would display information by going forward in time rather
than backward. For example, while the Lag function can return historical
data from one year ago, the same formula used for the Lead function
would return historical data from one year ahead.

The Lead function does not predict future values. For functions that can
predict future values based on historical data, see ForecastV (Forecast,
Vector Input), page 453, GrowthV (Growth, Vector Input), page 459, and
TrendV (Trend, Vector Input), page 488. Additionally, you can use data
mining functions from MicroStrategy Data Mining Services to predict
future trends, as described in Data Mining Functions, page 343.

For example, a Last Year's Monthly Revenue metric can be created using
the following function:

Lag<SortBy=(Month@ID)>(Revenue,12,ZeroToNull(0))

This metric can then be included on a report with the Month attribute and the
Revenue metric, as shown below.

Copyright © 2023 All Rights Reserved 203


Fu n ct io n s Refer en ce

This allows you to perform a side-by-side comparison of monthly revenue for


different years. In this report, the 2007 monthly revenue is displayed next to
the 2008 monthly revenue. The element Jan 2009 is included to show that
the Last Year's Monthly Revenue is displaying the monthly revenue from the
previous year.

By modifying the offset of the Lag function, you can change the time periods
that can be compared side by side. For example, the function listed above
uses an offset of 12, which displays monthly data from one year ago. Using
an offset of 3 would display monthly data from three months ago, while using
an offset of 24 would display monthly data from two years ago. These slight
modifications could be used to create separate metrics that could all be
included on the same report. The report below shows an example of
including three different metrics that use the same Lag formula with a
different offset.

Copyright © 2023 All Rights Reserved 204


Fu n ct io n s Refer en ce

The report shown above allows side-by-side comparison of monthly revenue


for three different time periods. In this report, the Monthly Revenue 2 Years
Ago metric displays no data for months in the year 2008 because no revenue
data exists for the year 2006.

To use the Lag or Lead functions for transformation-style analysis, the


metric formulas must be created to support the required reporting scenario.
For example, the report with the Month attribute and the Revenue metric has
the Category attribute added to it. To support this reporting scenario, you
can modify the Lag formula described above to include the Category
attribute, as shown below.

Lag<BreakBy={Category},SortBy=(Month@ID)> (Revenue,12,ZeroToNull
(0))

Copyright © 2023 All Rights Reserved 205


Fu n ct io n s Refer en ce

Using the formula shown above, the calculation is restarted for each
category, which allows the side-by-side comparison of monthly revenue over
time for each category, as shown in the report below:

Only the Month attribute elements Jan 2007, Jan 2008, and Jan 2009 are
displayed to show that the Last Year's Monthly Revenue (Category) metric is
displaying the monthly revenue from the previous year.

LastInRange
Returns the last value in a range of values. LastInRange can be used to
examine data such as inventory at the end of each month.

Calculations can be restarted based on attributes set in the function


parameters. This restart capability differentiates LastInRange from Last.
While Last is a group-value function and takes both facts and metrics as
argument input, LastInRange is an OLAP function and takes only metrics
as argument input.

Syntax

LastInRange <BreakBy={}, SortBy=()> (Argument)

Where:

Copyright © 2023 All Rights Reserved 206


Fu n ct io n s Refer en ce

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

Expression

Where:

l k = row number

l y k = last non-NULL value of the metric after applying the BreakBy and
SortBy parameters

Lead
The Lead function is useful to display a set of metric values in an order
determined by another metric or attribute on the report. This allows you to
compare metric values side-by-side. The easiest way to understand the
Lead function is with an example, provided below.

Syntax

Lead <BreakBy, SortBy> (Argument, Offset, DefaultValue)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is an attribute or metric representing a list of values. It is


common to use a metric for Argument.

l Offset specifies the offset from the current row to display information for.
This offset precedes ahead of the current row (you can use the Lag
function to use an offset that trails behind the current row, see Lag, page

Copyright © 2023 All Rights Reserved 207


Fu n ct io n s Refer en ce

200). For example, with an offset of two, row one displays data for the row
two ahead of it, which would be row three.

l DefaultValue is the value displayed for any entries that do not have any
data due to the offset. For example, when using an offset of 2, the last two
entries use the default value.

Some common default values to display include:

l 0: To display a value of 0 for any entries that do not have any data due
to the offset, type 0.

l No data: To display no data for any entries that do not have any data due
to the offset, type ZeroToNull(0).

Example

For an example of using Lag and Lead functions to perform transformation-


style analysis, see Transformation-Style Analysis Using the Lag and Lead
Functions, page 203.

On a report with Item, Cost, and Profit, you can use the Lead function to
create a Cost (Lead on Profit) metric. This metric displays Cost values
based on the descending sort order of the Profit metric, and is defined with
the following expression:

Lead<SortBy= (Profit Desc) >(Cost, 3.0, 0.0)

Notice that the offset is set to three, meaning that the display of cost values
is displayed three ahead of the current value. This is displayed in the report
results shown below.

Only the top and the bottom of the report is shown. To view the entire report
results, you can create this report in the MicroStrategy Tutorial project.

Copyright © 2023 All Rights Reserved 208


Fu n ct io n s Refer en ce

The Cost (Lead on Profit) values are displayed three ahead of the Cost
metric, and are displayed based on the descending sort order of Profit.
Notice that with an offset of three, the last three entries for Cost (Lead on
Profit) use the default value of zero. Also, the first three values of Cost are
not included in the Cost (Lead on Profit) metric.

The report has been sorted based on the Profit metric to make the Cost
(Lead on Profit) values easier to analyze.

MovingAvg (Moving Average)


Returns the moving average of the current value and preceding values, as
defined by the WindowSize parameter. The calculations can be restarted
based on attributes set in the function parameters. This is an OLAP function.

Syntax

MovingAvg <BreakBy={}, SortBy=()> (Argument, WindowSize)

Copyright © 2023 All Rights Reserved 209


Fu n ct io n s Refer en ce

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize is a positive integer indicating the number of values to use in


each calculation.

Expression

Where:

l y i = metric value at the i th row

l m= window size

l n = number of rows/metric values

Example

This simple example illustrates how the MovingAvg function calculates a


list of values and returns the average of a specified number of values. In this
case, the window size is set to 3, meaning that the value in the
MovingAverage column represents the average of the current value of the
two values that precede it in the value list. The calculation is shown in the
following table.

Values MovingAverage

10 10 (10/1)

Copyright © 2023 All Rights Reserved 210


Fu n ct io n s Refer en ce

Values MovingAverage

20 15 ((20+10) / 2)

30 20 ((30+20+10) / 3)

15 51.67 ((15+30+20) / 3)

5 16.67 ((5+15+30) / 3)

20 13.34 ((20+5+15) / 3)

40 21.67 ((40+20+5) / 3)

As an additional example, the Human Resources Analysis Module project


includes the Division Breakdown report shown below.

This report displays details about employee headcounts for each division,
over the various quarters of 2010. Included in this report is the metric
MovingAvg. It is defined as a derived metric, using the following expression:

MovingAvg<BreakBy={Division}, SortBy=(Quarter)> (Employees, 4.0)

Copyright © 2023 All Rights Reserved 211


Fu n ct io n s Refer en ce

This expression calculates the moving average of employee headcount for a


given division, during the four quarters of 2010. The window size of 4.0
specifies that the average is calculated across the four quarters, and
BreakBy={Divison} ensures that the moving average calculation is
specific to each division.

Using this MovingAvg metric, you can determine that the Sales division had
between 13.0 and 16.3 employees on average during the 2010 year, with
slight increases throughout the year.

For an extension of this example on how you can also use a weighted
moving average, see ExpWghMovingAvg (Exponential Weighted Moving
Average), page 192.

MovingCount
Returns the moving count of a list of values. The calculation can be
restarted based on attributes set in the function parameters. This is an
OLAP function.

Syntax

MovingCount <BreakBy={}, SortBy=()> (Argument, WindowSize)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of values.

l WindowSize is a positive integer indicating the highest number to use in


the count.

Expression

Copyright © 2023 All Rights Reserved 212


Fu n ct io n s Refer en ce

Where:

l y i = metric value at the i th row

l m= window size

l n = number of rows/metric values

l 1 i = 1 if the value at the i th row is not NULL

l 1 i = 0 otherwise

Usage Notes

If there are more entries in a section than the integer in the window size
parameter, then all the remaining entries are given the highest number in the
count. For example, if the window size is 4 and there are 6 entries in the list
section, they are counted as follows: 1,2,3,4,4,4.

Example

This simple example demonstrates how the MovingCount function counts


rows of data. This report uses the attributes Region and Employee, and the
metrics Revenue and Moving Count. A filter is applied so the only Regions
displayed are South, Northwest, and Southwest. The Moving Count metric is
defined as follows:

MovingCount<BreakBy={Region}, SortBy= (Value) >(Revenue, 3.0)

l The count restarts for every Region.

Copyright © 2023 All Rights Reserved 213


Fu n ct io n s Refer en ce

l The entries are counted based on the value of the metric Revenue in
ascending order (the lowest value is counted as 1, next lowest is 2, and so
on).

l The highest number in the count is 3 as designated in the WindowSize


parameter.

MovingDifference
Returns the moving difference between current and preceding values. The
position of the preceding row used in the calculation is defined in the
function arguments. The calculations can be restarted based on attributes
set in the function parameters. This is an OLAP function.

Syntax

MovingDifference <BreakBy, SortBy> (Argument, WindowSize)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize is a positive integer indicating the range of values used to


compute each difference.

Expression
Copyright © 2023 All Rights Reserved 214
Fu n ct io n s Refer en ce

Where:

l y i = metric value at the i th row

l m = window size

l n = number of rows/metric values

Example

This example illustrates how the MovingDifference function subtracts the


value of a preceding row from the value of the current row and returns the
difference. In this case, the window size is set to 3, meaning that the value
two rows previous to the current row is subtracted from the current row. In
other words, there are 3 rows in the window, the current row is 3, the row
immediately preceding it is 2, and the row preceding that is 1; therefore, the
calculation for the moving difference of row 3 is (row 3 - row 1).

The value in the MovingDifference column represents the result of the


calculation for every window of three values. The calculation is also shown.

Values MovingDifference

400

500

700 300 (700-400)

300 -200 (300-500)

600 -100 (600-700)

800 500 (800-300)

200 -400 (200-600)

Copyright © 2023 All Rights Reserved 215


Fu n ct io n s Refer en ce

MovingMax (Moving Maximum)


Returns the moving maximum value by comparing current and preceding
rows as defined in the function arguments. The calculation can be restarted
based on attributes set in the function parameters. This is an OLAP function.

Syntax

MovingMax <BreakBy, SortBy> (Argument, WindowSize)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize is a positive integer indicating the number of values to


compare in each calculation.

Expression

Where:

l y i = metric value at the i th row

l m = window size

l n = number of rows/metric values

Example

This simple example illustrates how the MovingMaximum function moves


through a list of values, subtracting a value from the user-defined number of
preceding rows. In this case, the window size is set to 3, meaning that the
value in the MovingMaximum column represents the highest value among

Copyright © 2023 All Rights Reserved 216


Fu n ct io n s Refer en ce

the current and preceding two values in the value list. The calculation is
shown in the following table.

Values MovingMaximum

550 550

30 550 (550>30)

40 550 (550>40 and 550>30)

70 70 (70>40 and 70>30)

50 70 (70>50 and 70>40)

MovingMin (Moving Minimum)


Compares the current value and preceding values as defined in the function
arguments to calculate a moving minimum value. The calculation can be
restarted based on attributes set in the function parameters. This is an
OLAP function.

Syntax

MovingMin <BreakBy,SortBy>(Argument, WindowSize)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize is a positive integer indicating the number of values to use in


each calculation.

Expression

Copyright © 2023 All Rights Reserved 217


Fu n ct io n s Refer en ce

Where:

l y i = metric value at the i th row

l m = window size

l n = number of rows/metric values

Example

This simple example illustrates how the MovingMin function moves through
a list of values returning the lowest value within a specified number of
values. In this case, the window size is set to 3, meaning that the value in
the MovingMinimum column represents the lowest value among the current
and preceding two values in the value list. The calculation is shown in the
following table.

Values MovingMinimum

550 550

30 30 (30<550)

40 30 (30<40 and 30<550)

70 30 (30<70 and 30<40)

50 40 (40<70 and 40<50)

MovingStDevP (Moving Standard Deviation of a Population)


Returns the moving standard deviation of a population based on a list of
values that encompasses the whole population. The calculation can be
restarted based on attributes set in the function parameters. This is an
OLAP function.

Syntax

MovingStDevP <BreakBy, SortBy> (Argument, WindowSize)

Where:

Copyright © 2023 All Rights Reserved 218


Fu n ct io n s Refer en ce

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

l WindowSize is a positive integer indicating the number of values to use in


each calculation.

Expression

Where:

l y i = metric value at the i th row

l y = average of metric

l m= window size

l n = number of rows/metric values

Example

This example shows a report where the moving standard deviation of the
revenue is calculated. This calculation is based on the assumption that the
list of values supplied in the metric represents the entire population of the
data for which you want to obtain the standard deviation. The calculation
starts over for each region, the information is sorted within the region by
state in ascending order, and each calculation is based upon a window size
of 3.

Compare this example report to the example for MovingStDev to see the
different values returned when calculating for a population as opposed to a
sample.

Copyright © 2023 All Rights Reserved 219


Fu n ct io n s Refer en ce

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue, MovingStDevP, RunningStDevP, and
StDevP. A report filter limits data to the South, Southwest, and Northwest
regions. The definition of the MovingStDevP metric is as follows:

MovingStDevP<BreakBy={[Customer Region]}, SortBy=<[Customer


State])>([Total Revenue],3)

MovingStDev (Moving Standard Deviation)


Returns the moving standard deviation based on a list of values that is a
sample of the population. The calculation can be restarted based on
attributes set in the function parameters. This is an OLAP function.

Syntax

MovingStDev <BreakBy, SortBy> (Argument, WindowSize)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of number.

Copyright © 2023 All Rights Reserved 220


Fu n ct io n s Refer en ce

l WindowSize is a positive integer indicating the number of values to use in


each calculation.

Expression

Where:

l yi = metric value at the i th row

l y = average of metric

l m = window size

l n = number of rows/metric values

Example

This example shows a report where the moving standard deviation of the
revenue is calculated. This calculation is based on the assumption that the
list of values supplied in the metric represents a sample of the data for which
you want to obtain the standard deviation. The calculation starts over for
each region, the information is sorted within the region by state in ascending
order, and each calculation is based upon a window size of 3.

Compare this example report to the example for MovingStDevP to see the
different values returned when calculating for a population as opposed to a
sample.

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue, MovingStDev, RunningStDev, and StDev. A
report filter limits data to the Southwest, Southeast, and Northwest regions.
The definition of the MovingStDev metric is as follows:

Copyright © 2023 All Rights Reserved 221


Fu n ct io n s Refer en ce

MovingStDev<BreakBy={[Customer Region]}, SortBy=<[Customer


State])>([Total Revenue], 3)

MovingSum
Returns the moving sum of the current value and preceding values as
defined in the function arguments. The calculations can be restarted based
on attributes set in the function parameters. This is an OLAP function.

Syntax

MovingSum <BreakBy,SortBy>(Argument, WindowSize)

Where:

l Argument is a metric representing a list of numbers.

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l WindowSize is a positive integer indicating the number of values to sum


in each calculation.

Expression

Copyright © 2023 All Rights Reserved 222


Fu n ct io n s Refer en ce

Where:

l y i = metric value at the i th row

l m = window size

l n = number of rows/metric values

Example

This simple example illustrates how the MovingSum function moves through
a list of values calculating and returning the sum of a specified number of
values. In this case the window size is set to 2 meaning that the sum in the
MovingSum column represents the current value added to the value from the
value list that precedes it. The calculation is shown in the following table.

Values MovingSum

10 10

20 30 (20+10)

30 50 (30+20)

15 45 (15+30)

5 20 (5+15)

OLAPAvg (OLAP Average)


Returns the average of the current value, preceding values, and succeeding
values as defined in the function arguments. Unlike RunningAvg and
MovingAvg, which can only include values above the current row in the

Copyright © 2023 All Rights Reserved 223


Fu n ct io n s Refer en ce

calculation, you can use OLAPAvg to include values both above and below
the current row in the calculation.

The calculations can be restarted based on attributes defined in the function


parameters.

Syntax

OLAPAvg<Distinct, OLAPWinStType, OLAPWinStOffset, OLAPWinEndType,


OLAPWinEndOffset, BreakBy, SortBy>(Argument)

Where:

l Distinct is a TRUE/FALSE parameter that allows you to use all values in


the calculation or to calculate using only the unique values. If you define
Distinct to be true, then the parameters OLAPWinStType,
OLAPWinStOffset, OLAPWinEndType, OLAPWinEndOffset, and
SortBy are ignored.

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l OLAPWinStType defines the window type for the starting location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinStType value in parentheses:

l Top of data set (0): The calculation starts at the top value as determined
by the BreakBy and SortBy values.

l Current row (2): The calculation starts at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

Copyright © 2023 All Rights Reserved 224


Fu n ct io n s Refer en ce

l OLAPWinStOffset defines the offset of rows from the current row to start
the calculation. You can define this offset if the OLAPWinStType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l OLAPWinEndType defines the window type for the ending location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinEndType value in parentheses:

l Bottom of data set (1): The calculation stops at the bottom value as
determined by the BreakBy and SortBy values.

l Current row (2): The calculation stops at the current row.

l N rows before current row (3): The calculation stops a number of rows
before the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l N rows after current row (4): The calculation stops a number of rows
after the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l OLAPWinEndOffset defines the offset of rows from the current row to


stop the calculation. You can define this offset if the OLAPWinEndType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l Argument is a metric representing a list of numbers.

The function is not valid if your starting point is at a lower point than your
ending point.

Example

An OLAPAvg Unit Cost metric is created using the OLAPAvg function based
on the Unit Cost metric, as defined below:

Copyright © 2023 All Rights Reserved 225


Fu n ct io n s Refer en ce

OLAPAvg<OLAPWinStType=3, OLAPWinStOffset=3, OLAPWinEndType=4,


OLAPWinEndOffset=2, BreakBy={Category} SortBy={Item}>([Unit
Cost])

The starting point for the average is defined as three rows before the current
row (OLAPWinStType=3, OLAPWinStOffset=3). The stopping point for
the average is defined as two rows after the current row
(OLAPWinEndType=4, OLAPWinEndOffset=2).

This metric is displayed on a report along with Category, Item, and Unit
Cost, as shown below.

There are a few facts about this data to take note of.

The first value of OLAPAvg Unit Cost is $15. This is calculated by adding
$32, $8, and $5 to get a total of $45. This total of $45 is then divided by
three (the number of rows included in the calculation) to get the final result
of $15. These rows are included because the calculation ends two rows after
the current row. Even though the calculation starts three rows before the
current row, there is no data above the current row to include in the
calculation.

Copyright © 2023 All Rights Reserved 226


Fu n ct io n s Refer en ce

The fourth value for OLAPAvg Unit Cost is the first value that can include
data from all three rows above the current row to two rows below the current
row in the calculation (($32 + $8 + $5 + $25 + $19 + $20) / 6 =
$18.17). Notice that with this calculation a value of six is used to calculate
the average because six rows were included in the average.

While it is not shown on this report, the calculation would restart for the first
Item of the next Category because the function is defined to break by the
Category attribute.

OLAPCount
Returns the count of the current value, preceding values, and succeeding
values as defined in the function arguments. Unlike RunningCount and
MovingCount, which can only include values above the current row in the
calculation, you can use OLAPCount to include values both above and below
the current row in the calculation.

The calculations can be restarted based on attributes defined in the function


parameters.

Syntax

OLAPCount<Distinct, Null, OLAPWinStType, OLAPWinStOffset,


OLAPWinEndType, OLAPWinEndOffset, BreakBy, SortBy>(Argument)

Where:

l Distinct is a TRUE/FALSE parameter that allows you to use all values in


the calculation or to calculate using only the unique values. If you define
Distinct to be true, then the parameters Null, OLAPWinStType,
OLAPWinStOffset, OLAPWinEndType, OLAPWinEndOffset, and
SortBy are ignored.

l Null is a TRUE/FALSE parameter that defines whether null values are


included in the total count.

l BreakBy is the attribute indicating where the calculation restarts.

Copyright © 2023 All Rights Reserved 227


Fu n ct io n s Refer en ce

l SortBy is the attribute or metric by which the data is sorted.

l OLAPWinStType defines the window type for the starting location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinStType value in parentheses:

l Top of data set (0): The calculation starts at the top value as determined
by the BreakBy and SortBy values.

l Current row (2): The calculation starts at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l OLAPWinStOffset defines the offset of rows from the current row to start
the calculation. You can define this offset if the OLAPWinStType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l OLAPWinEndType defines the window type for the ending location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinEndType value in parentheses:

l Bottom of data set (1): The calculation stops at the bottom value. The
top value is determined by the BreakBy and SortBy values.

l Current row (2): The calculation stops at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

Copyright © 2023 All Rights Reserved 228


Fu n ct io n s Refer en ce

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l OLAPWinEndOffset defines the offset of rows from the current row to


stop the calculation. You can define this offset if the OLAPWinEndType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l Argument is a metric representing a list of numbers.

The function is not valid if your starting point is at a lower point than your
ending point.

Example

An OLAPCount Unit Cost metric is created using the OLAPCount function


based on the Unit Cost metric, as defined below:

OLAPCount<OLAPWinStType=3, OLAPWinStOffset=3, OLAPWinEndType=4,


OLAPWinEndOffset=2, BreakBy={Category} SortBy={Subcategory}>
([Unit Cost])

The starting point for the count is defined as three rows before the current
row (OLAPWinStType=3, OLAPWinStOffset=3). The stopping point for
the count is defined as two rows after the current row
(OLAPWinEndType=4, OLAPWinEndOffset=2).

This metric is displayed on a report along with Category, Subcategory, and


Unit Cost, as shown below.

Copyright © 2023 All Rights Reserved 229


Fu n ct io n s Refer en ce

There are a few facts about this data to take note of.

The first value of OLAPCount Unit Cost is three. This is calculated by


counting the current row and two rows after the current row. Even though the
calculation starts three rows before the current row, there is no data above
the current row to include in the calculation.

The fourth entry for OLAPCount Unit Cost is the first entry that can count all
three rows above the current row to two rows below the current row in the
calculation. This entry is able to reach the maximum value of six. Notice that
after this entry the count begins to decrease because there are no longer
two rows below the current row to include in the calculation.

The calculation restarts for the first Subcategory of the next Category
because the function is defined to break by the Category attribute.

Copyright © 2023 All Rights Reserved 230


Fu n ct io n s Refer en ce

OLAPMax (OLAP Maximum)


Returns the maximum value based on comparing the current value,
preceding values, and succeeding values as defined in the function
arguments. Unlike RunningMax and MovingMax, which can only include
values above the current row in the calculation, you can use OLAPMax to
include values both above and below the current row in the calculation.

The calculations can be restarted based on attributes defined in the function


parameters.

Syntax

OLAPMax<OLAPWinStType, OLAPWinStOffset, OLAPWinEndType,


OLAPWinEndOffset, BreakBy, SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l OLAPWinStType defines the window type for the starting location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinStType value in parentheses:

l Top of data set (0): The calculation starts at the top value as determined
by the BreakBy and SortBy values.

l Current row (2): The calculation starts at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

Copyright © 2023 All Rights Reserved 231


Fu n ct io n s Refer en ce

l OLAPWinStOffset defines the offset of rows from the current row to start
the calculation. You can define this offset if the OLAPWinStType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l OLAPWinEndType defines the window type for the ending location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinEndType value in parentheses:

l Bottom of data set (1): The calculation stops at the bottom value. The
top value is determined by the BreakBy and SortBy values.

l Current row (2): The calculation stops at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l OLAPWinEndOffset defines the offset of rows from the current row to


stop the calculation. You can define this offset if the OLAPWinEndType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l Argument is a metric representing a list of numbers.

The function is not valid if your starting point is at a lower point than your
ending point.

Example

An OLAPMax Unit Cost metric is created using the OLAPMax function based
on the Unit Cost metric, as defined below:

Copyright © 2023 All Rights Reserved 232


Fu n ct io n s Refer en ce

OLAPMax<OLAPWinStType=3, OLAPWinStOffset=3, OLAPWinEndType=4,


OLAPWinEndOffset=2, BreakBy={Category} SortBy={Subcategory}>
([Unit Cost])

The starting point for the calculation is defined as three rows before the
current row (OLAPWinStType=3, OLAPWinStOffset=3). The stopping
point for the calculation is defined as two rows after the current row
(OLAPWinEndType=4, OLAPWinEndOffset=2).

This metric is displayed on a report along with Category, Subcategory, and


Unit Cost, as shown below.

There are a few facts about this data to take note of.

The first value of OLAPMax Unit Cost is $14. This is calculated by returning
the maximum value of $14, $11, and $6. These are included because the

Copyright © 2023 All Rights Reserved 233


Fu n ct io n s Refer en ce

calculation ends two rows after the current row. Even though the calculation
starts three rows before the current row, there is no data above the current
row to include in the calculation.

The second value also returns $14 as it returns the maximum value of $14,
$11, $6, and $7.

The third value for OLAPMax Unit Cost is the first entry that includes $26 in
its maximum calculation. The rest of the OLAPMax Unit Cost values for the
Books Category return $26 because this is the maximum value, and it is
within the window of three rows above the current row to two rows below the
current row.

The calculation restarts for the first Subcategory of the next Category
because the function is defined to break by the Category attribute.

OLAPMin (OLAP Minimum)


Returns the minimum value based on comparing the current value,
preceding values, and succeeding values as defined in the function
arguments. Unlike RunningMin and MovingMin, which can only include
values above the current row in the calculation, you can use OLAPMin to
include values both above and below the current row in the calculation.

The calculations can be restarted based on attributes defined in the function


parameters.

Syntax

OLAPMin<OLAPWinStType, OLAPWinStOffset, OLAPWinEndType,


OLAPWinEndOffset, BreakBy, SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

Copyright © 2023 All Rights Reserved 234


Fu n ct io n s Refer en ce

l OLAPWinStType defines the window type for the starting location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinStType value in parentheses:

l Top of data set (0): The calculation starts at the top value as determined
by the BreakBy and SortBy values.

l Current row (2): The calculation starts at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l OLAPWinStOffset defines the offset of rows from the current row to start
the calculation. You can define this offset if the OLAPWinStType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l OLAPWinEndType defines the window type for the ending location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinEndType value in parentheses:

l Bottom of data set (1): The calculation stops at the bottom value. The
top value is determined by the BreakBy and SortBy values.

l Current row (2): The calculation stops at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

Copyright © 2023 All Rights Reserved 235


Fu n ct io n s Refer en ce

l OLAPWinEndOffset defines the offset of rows from the current row to


stop the calculation. You can define this offset if the OLAPWinEndType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l Argument is a metric representing a list of numbers.

The function is not valid if your starting point is at a lower point than your
ending point.

Example

An OLAPMin Unit Cost metric is created using the OLAPMin function based
on the Unit Cost metric, as defined below:

OLAPMin<OLAPWinStType=3, OLAPWinStOffset=3, OLAPWinEndType=4,


OLAPWinEndOffset=2, BreakBy={Category} SortBy={Subcategory}>
([Unit Cost])

The starting point for the calculation is defined as three rows before the
current row (OLAPWinStType=3, OLAPWinStOffset=3). The stopping
point for the calculation is defined as two rows after the current row
(OLAPWinEndType=4, OLAPWinEndOffset=2).

This metric is displayed on a report along with Category, Subcategory, and


Unit Cost, as shown below.

Copyright © 2023 All Rights Reserved 236


Fu n ct io n s Refer en ce

There are a few facts about this data to take note of.

The first value of OLAPMinUnit Cost is $6. This is calculated by returning the
minimum value of $14, $11, and $6. These are included because the
calculation ends two rows after the current row. Even though the calculation
starts three rows before the current row, there is no data above the current
row to include in the calculation.

All of the OLAPMin Unit Cost values for the Books Category return $6
because this is the minimum value, and it is within the window of three rows
above the current row to two rows below the current row.

The calculation restarts for the first Subcategory of the next Category
because the function is defined to break by the Category attribute.

Copyright © 2023 All Rights Reserved 237


Fu n ct io n s Refer en ce

OLAPRank
Returns the rank of the current value based on the other values defined by
the sorting criteria. The ranking can be restarted based on attributes defined
in the function parameters.

The OLAPRank function allows the ranking to be calculated in the database,


rather than calculating the ranking using the MicroStrategy Analytical
Engine.

l Since OLAPRank is calculated in the database, you can only use this
function if your database supports the OLAPRank function.

l Any metrics that use the OLAPRank function must not be defined as smart
metrics. If metrics that use OLAPRank are defined as smart metrics, the
calculation is performed in the MicroStrategy Analytical Engine and an
error is returned.

l You must include at least one metric in the SortBy parameter.

Syntax

OLAPRank<BreakBy, SortBy>()

Where:

l BreakBy is the attribute indicating where the ranking restarts.

l SortBy is the attribute or metric by which the data is sorted. For


OLAPRank, the SortBy parameter is also where you can include the
metric to perform the calculation on. You must include at least one metric
in the SortBy parameter.

Example

The MicroStrategy Tutorial project includes an Avg Revenue per Customer


metric. This metric can be placed on a report along with the attributes
Quarter and Region to display the quarterly average revenue per customer
for each region.

Copyright © 2023 All Rights Reserved 238


Fu n ct io n s Refer en ce

To extend this analysis, you can create an OLAPRank Avg Rev per
Customer metric as defined below:

OLAPRank<BreakBy={Quarter}, SortBy= ([Avg Revenue per Customer],


Region@ID) >()

When this metric is included on a report with Quarter, Region, and Avg
Revenue per Customer, it displays the regional rank of the quarterly average
revenue per customer for each region. This is shown in the report below.

The report has been sorted by Quarter, and then by the OLAPRank Avg Rev
per Customer values.

The report shown above displays regions based on their average revenue
per customer for each quarter, sorted from the lowest average revenue per

Copyright © 2023 All Rights Reserved 239


Fu n ct io n s Refer en ce

customer to the highest. This analysis allows you to quickly see how regions
are performing based on average revenue per customer over different
quarters. In the first three quarters of data shown above, Web has the lowest
average revenue per customer. However, there is some variation in the
performance of the other regions. Performing this analysis over extended
periods of time can help to show trends in revenue and regional
performance.

OLAPSum
Returns the summation of the current value, preceding values, and
succeeding values as defined in the function arguments. Unlike
RunningSum and MovingSum, which can only include values above the
current row in the calculation, you can use OLAPSum to include values both
above and below the current row in the calculation.

The calculations can be restarted based on attributes defined in the function


parameters.

Syntax

OLAPSum<Distinct, OLAPWinStType, OLAPWinStOffset, OLAPWinEndType,


OLAPWinEndOffset, BreakBy, SortBy>(Argument)

Where:

l Distinct is a TRUE/FALSE parameter that allows you to use all values in


the calculation or to calculate using only the unique values. If you define
Distinct to be true, then the parameters OLAPWinStType,
OLAPWinStOffset, OLAPWinEndType, OLAPWinEndOffset, and
SortBy are ignored.

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l OLAPWinStType defines the window type for the starting location of the
calculation. Select one of the following options, listed by the name of the

Copyright © 2023 All Rights Reserved 240


Fu n ct io n s Refer en ce

setting and its corresponding OLAPWinStType value in parentheses:

l Top of data set (0): The calculation starts at the top value as determined
by the BreakBy and SortBy values.

l Current row (2): The calculation starts at the current row.

l N rows before current row (3): The calculation starts a number of rows
before the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l N rows after current row (4): The calculation starts a number of rows
after the current row. You define this offset of rows with the
OLAPWinStOffset parameter described below.

l OLAPWinStOffset defines the offset of rows from the current row to start
the calculation. You can define this offset if the OLAPWinStType
parameter is defined as N rows before current row (3) or N rows after
current row (4).

l OLAPWinEndType defines the window type for the ending location of the
calculation. Select one of the following options, listed by the name of the
setting and its corresponding OLAPWinEndType value in parentheses:

l Bottom of data set (1): The calculation stops at the bottom value. The
top value is determined by the BreakBy and SortBy values.

l Current row (2): The calculation stops at the current row.

l N rows before current row (3): The calculation stops a number of rows
before the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l N rows after current row (4): The calculation stops a number of rows
after the current row. You define this offset of rows with the
OLAPWinEndOffset parameter described below.

l OLAPWinEndOffset defines the offset of rows from the current row to


stop the calculation. You can define this offset if the OLAPWinEndType

Copyright © 2023 All Rights Reserved 241


Fu n ct io n s Refer en ce

parameter is defined as N rows before current row (3) or N rows after


current row (4).

l Argument is a metric representing a list of numbers.

The function is not valid if your starting point is at a lower point than your
ending point.

Example

An OLAPSum Unit Cost metric is created using the OLAPSum function


based on the Unit Cost metric, as defined below:

OLAPSum<OLAPWinStType=3, OLAPWinStOffset=3, OLAPWinEndType=4,


OLAPWinEndOffset=2, BreakBy={Category} SortBy={Subcategory}>
([Unit Cost])

The starting point for the summation is defined as three rows before the
current row (OLAPWinStType=3, OLAPWinStOffset=3). The stopping
point for the summation is defined as two rows after the current row
(OLAPWinEndType=4, OLAPWinEndOffset=2).

This metric is displayed on a report along with Category, Subcategory, and


Unit Cost, as shown below.

Copyright © 2023 All Rights Reserved 242


Fu n ct io n s Refer en ce

There are a few facts about this data to take note of.

The first value of OLAPSum Unit Cost is $30.82. This is calculated by adding
$13.93, $10.75, and $6.13. These are included because the calculation ends
two rows after the current row. Even though the calculation starts three rows
before the current row, there is no data above the current row to include in
the calculation.

The data displayed on the report is rounded to the nearest cent, which can
give the impression that some calculations are slightly incorrect. For
example, adding $13.93, $10.75, and $6.13 actually totals $30.81 rather
than $30.82 as displayed on the report. This difference is because the data
is rounded up for display on the report. You can display more decimal
values for the Unit Cost and OLAPSum Unit Cost metrics to see the exact
values.

Copyright © 2023 All Rights Reserved 243


Fu n ct io n s Refer en ce

The fourth value for OLAPSum Unit Cost is the only value that can include
data from all three rows above the current row to two rows below the current
row in the calculation ($13.93 + $10.75 + $6.13 + $7.20 + $25.93
+ $9.43 = $73.38).

The final OLAPSum Unit Cost value for the Books Category can only include
the Unit Cost value for the current row and the three rows above it ($6.13 +
$7.20 + $25.93 + $9.43 = $48.70). It cannot include two rows below
the current row because the calculation restarts for the first Subcategory of
the next Category. The calculation restarts because the function is defined
to break by the Category attribute.

RunningAvg (Running Average)


Moves through the values in a list and returns the running average, adding
the current value to the sum of the preceding values and dividing by the
current count of values. The calculation can restart based on attribute
groupings identified in the parameter settings. This is an OLAP function.

Syntax

RunningAvg <BreakBy,SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing a list of numbers.

Expression

Where:

Copyright © 2023 All Rights Reserved 244


Fu n ct io n s Refer en ce

l y i = metric value at the i th row

l m = window size

l n = number of rows/metric values

Example

This simple example illustrates how the RunningAverage function walks


through a list of values calculating and returning the new average with the
addition of each value. The calculation is shown in the following table.

Values RunningAverage

10 10 (10/1)

20 15 (30/2)

30 20 (60/3)

40 25 (100/4)

50 30 (150/5)

RunningCount
Returns the running count for each value in a list of values, returning the
current count after each value. The count can be restarted based upon
attributes identified in the parameter settings. This is an OLAP function.

Syntax

RunningCount<BreakBy,SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing the list of values.

Expression

Copyright © 2023 All Rights Reserved 245


Fu n ct io n s Refer en ce

Where:

l 1 i = 0 if the i th row of argument is NULL

1 i = 1 otherwise

l n = number of rows/metric values

Example

This simple example demonstrates how the RunningCount function counts


rows of data. This report uses the attributes Region and Employee, and the
metrics Revenue and Running count. A filter is applied so the only Regions
displayed are South, Northwest, and Southwest. The Running count metric
is defined as follows:

RunningCount<BreakBy={Region}, SortBy= (Value) >(Revenue)

l The count restarts for every Region.

l The entries are counted based on the value of the metric Revenue in
ascending order (the lowest value is counted as 1, next lowest is 2, and so
on).

Copyright © 2023 All Rights Reserved 246


Fu n ct io n s Refer en ce

RunningMax (Running Maximum)


Returns the running maximum value in a list of values by comparing the
current and preceding values. The evaluation can restart based on attributes
identified in the parameter settings. This is an OLAP function.

Syntax

RunningMax <BreakBy, SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing the list of numbers.

Expression

Where:

l y i = metric value at the i th row

l n = number of rows/metric values

Example

This simple example illustrates how the RunningMax function moves through
a list of values comparing each value to the highest value identified so far
and returning the maximum value as it progresses. The calculation is shown
in the following table.

Values RunningMaximum

Copyright © 2023 All Rights Reserved 247


Fu n ct io n s Refer en ce

Values RunningMaximum

6 8 (8>6)

10 10 (10>8)

9 10 (10>9)

5 10 (10>5)

RunningMin (Running Minimum)


Returns the running minimum value in a list of values by comparing current
and preceding values. The evaluation can restart based on attributes
identified in the parameter settings. This is an OLAP function.

Syntax

RunningMin <BreakBy, SortBy> (Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing the list of numbers.

Expression

Where:

l y i = metric value at the i th row

l n = number of rows/metric values

Example

Copyright © 2023 All Rights Reserved 248


Fu n ct io n s Refer en ce

This simple example illustrates how the RunningMinimum function walks


through a list of values comparing each value to the lowest value identified
so far and returning the minimum value as it progresses. The calculation is
shown in the following table.

Values RunningMinimum

6 6 (6<8)

10 6 (6<10)

9 6 (6<9)

5 5 (5<6)

RunningStDevP (Running Standard Deviation of a Population)


Returns the running standard deviation of a population for a value
expression. The list of values supplied is the population. The calculation can
restart based on attributes identified in the function parameter settings. This
is an OLAP function.

Syntax

RunningStDevP <BreakBy, SortBy> (Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing the list of numbers.

Expression

Copyright © 2023 All Rights Reserved 249


Fu n ct io n s Refer en ce

Where:

l y i = metric value at the i th row

l n = number of rows/metric values

Example

This example shows a report where the running standard deviation of the
revenue is calculated. This calculation is based on the assumption that the
list of values supplied in the metric represents the entire population of the
data for which you want to obtain the standard deviation. The calculation
starts over for each region, and the information is sorted within the region by
state in ascending order.

Compare this example report to the example for RunningStDev to see the
different values returned when calculating for a population as opposed to a
sample.

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue, RunningStDevP, and StDevP. A report filter
limits data to the Southwest, Southeast, and Northwest regions. The
definition of the RunningStDevP metric is as follows:

RunningStDevP<BreakBy={[Customer Region]}, SortBy=<[Customer


State])>([Total Revenue])

Copyright © 2023 All Rights Reserved 250


Fu n ct io n s Refer en ce

RunningStDev (Running Standard Deviation)


Returns the running standard deviation of a sample for a value expression.
The list of values supplied is the sample. The calculation can restart based
on attributes identified in the function parameters. This is an OLAP function.

Syntax

RunningStDev<BreakBy,SortBy>(Argument)

Where:

l BreakBy is the attribute indicating where the calculation restarts.

l SortBy is the attribute or metric by which the data is sorted.

l Argument is a metric representing the list of numbers.

Expression

Example

Copyright © 2023 All Rights Reserved 251


Fu n ct io n s Refer en ce

This example shows a report where the running standard deviation of the
revenue is calculated. This calculation is based on the assumption that the
list of values supplied in the metric represents a sample of the data for which
you want to obtain the standard deviation. The calculation starts over for
each region, and the information is sorted within the region by state in
ascending order.

Compare this example report to the example for RunningStDevP to see the
different values returned when calculating for a population as opposed to a
sample.

The report contains the attributes Customer Region and Customer State,
and the metrics Total Revenue, RunningStDev, and StDev. A report filter is
used to limit the data to the Southwest, Southeast and Northwest regions.
The definition of the RunningStDev metric is as follows:

RunningStDev<BreakBy={[Customer Region]}, SortBy=<[Customer


State])>([Total Revenue])

RunningSum
This function returns the running sum of the values in a list, adding the
current value to the preceding values. It can be used to maintain running

Copyright © 2023 All Rights Reserved 252


Fu n ct io n s Refer en ce

totals of values in specific categories as well as an entire set. The


calculation can restart based on attributes identified in the parameter
settings. This is an OLAP function.

Syntax

RunningSum <BreakBy,SortBy>(Argument)

Where:

l BreakBy is the parameter that sets the attribute designating where the
calculation restarts.

l SortBy is the parameter that sets the attribute or metric by which the data
is sorted.

l Argument is a metric representing the list of numbers.

Expression

Example

Example 1: A running sum displays the results of each calculation as it


works towards the total of a set of values. Using the value set (1, 2, 3, 4, 5),
the following table illustrates the running sum and its calculations.

Values RunningSum

1 1 (0+1)

2 3 (1+2)

3 6 (3+3)

4 10 (6+4)

5 15 (10+5)

Copyright © 2023 All Rights Reserved 253


Fu n ct io n s Refer en ce

Example 2: This example shows a report where the running sum of the
revenue is calculated. The calculation starts over for each region, and the
information is sorted within the region by state in ascending order. The
report contains the attributes Customer Region and Customer State, and the
metrics Total Revenue and Running Sum. A report filter limits data to the
Southwest, Southeast, and Northwest regions. The definition of the Running
Sum metric is as follows:

RunningSum<BreakBy={[Customer Region]}, SortBy=<[Customer


State])>([Total Revenue])

Note that the subtotaled Total Revenue is equal to the last value in the
Running Sum column for each region.

WeightedCorr (Weighted Correlation)


A correlation of two values describes the degree to which the values are
related or associated. Values that are closely related with either a positive

Copyright © 2023 All Rights Reserved 254


Fu n ct io n s Refer en ce

or negative correlation will have a correlation close to 1 or -1 respectively,


while values that are not correlated at all will have a correlation close to 0.

A weighted correlation allows you to apply a weight, or relative significance


to each value comparison. Correlation comparisons with a higher value for
their weight are considered as more significant when compared to the other
value comparisons.

To determine the correlation of two values without applying a weight to the


comparisons, see Correlation, page 446.

Syntax

WeightedCorr <FactID> (Argument1, Argument2, Weight)

Where:

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

l Argument1 and Argument2 are attributes, facts, or metrics representing


lists of numbers for comparison. A correlation is calculated on these
values to determine the level of association between the two values.

l Weight is an attribute, fact, or metric representing a list of numbers to


define the weight of each comparison.

Expression

Where:

l x and y are the values being compared.

l w is the weight applied to each comparison.

Usage Notes

Copyright © 2023 All Rights Reserved 255


Fu n ct io n s Refer en ce

l The correlation coefficient is measured on a scale that varies from 1 to - 1.


So only a value between -1 and 1 is returned.

l Complete correlation between two variables is expressed by either 1 or -1.


When one variable increases as the other increases, the correlation is
positive. When one decreases as the other increases, the correlation is
negative. Complete absence of correlation is represented by 0.

l If an array or reference argument contains text, logical values, or empty


cells, those values are ignored; however, cells with the value zero are
included.

l If Argument1 and Argument2 have a different number of data points, an


error is returned.

l If either Argument1 or Argument2 is empty, or if the standard deviation


of their values equals zero, an error is returned.

Example

Your company keeps employee statistics including their overall satisfaction


with their job and role at the company, as well as their performance score.
While these are both important statistics, it can also be beneficial to know
how closely related these two statistics are. Knowing this information can
help determine if an employee's satisfaction with their job is related to their
performance.

A report including both the correlation and weighted correlation of these


statistics, displayed as percentages, is shown below for employees at the
executive level:

Copyright © 2023 All Rights Reserved 256


Fu n ct io n s Refer en ce

The expressions for these calculations are as follows:

l Correlation:

Correlation([Avg. Performance Score], [Avg. Satisfaction


Score]) {Level , ~ }

l Weighted Correlation:

WeightedCorr([Avg. Performance Score], [Avg.


Satisfaction Score], Tenure) {Level, ~}

Both the correlation and weighted correlation indicate that employee


satisfaction and performance are positively correlated, meaning that when
one increases so does the other. The weighted correlation includes an
employee's tenure into the correlation calculation. This means that more
significance is given to correlation comparisons for employees that have
been with the company longer.

For the executive level employees, factoring in tenure results in a smaller


correlation between satisfaction and performance. This type of analysis can
be crucial in determining how performance can be improved or maintained
both for new hires and long tenured employees.

WeightedCov (Weighted Covariance)


Covariance is used to examine the relationship between two data sets. For
instance, the covariance can be used to examine whether an increase in
income is related to higher education levels. A covariance greater or less
than zero indicates a relationship, while a value of zero indicates no
relationship.

A weighted covariance allows you to apply a weight, or relative significance


to each value comparison. Covariance comparisons with a higher value for
their weight are considered as more significant when compared to the other
value comparisons.

Copyright © 2023 All Rights Reserved 257


Fu n ct io n s Refer en ce

To determine the covariance of two values without applying a weight to the


comparisons, see Covariance, page 447.

Syntax

WeightedCov <FactID> (Argument1, Argument2, Weight)

Where:

l Argument1 and Argument2 are attributes, facts, or metrics representing


lists of numbers for comparison. A covariance is calculated on these
values to determine the level of association between the two values.

l Weight is an attribute, fact, or metric representing a list of numbers to


define the weight of each comparison.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

l x and y are the Argument1 and Argument2 values being compared.

l w is the weight applied to each comparison.

l
= average value of x

= average value of y
l

Usage Notes

The following are invalid conditions:

l If an array or reference argument contains text, logical values, or empty


cells, those values are ignored; however, cells with the value zero are
included.

Copyright © 2023 All Rights Reserved 258


Fu n ct io n s Refer en ce

l If Argument1 and Argument2 have a different number of data points, an


error is returned.

l If either Argument1 or Argument2 is empty, an error is returned.

Example

Your company keeps employee statistics including their overall satisfaction


with their job and role at the company, as well as their performance score.
While these are both important statistics, it can also be beneficial to know
how closely related these two statistics are. Knowing this information can
help determine if an employee's satisfaction with their job is related to their
performance.

A report including both the covariance and weighted covariance of these


statistics, is shown below for employees at the executive level:

The expressions for these calculations are as follows:

l Covariance:

Covariance([Avg. Performance Score], [Avg. Satisfaction


Score]) {Level , ~ }

l Weighted Covariance:

WeightedCov([Avg. Performance Score], [Avg. Satisfaction


Score], Tenure) {Level, ~}

Both the covariance and weighted covariance indicate that employee


satisfaction and performance are positively related, meaning that when one

Copyright © 2023 All Rights Reserved 259


Fu n ct io n s Refer en ce

increases so does the other. The weighted covariance includes an


employee's tenure into the covariance calculation. This means that more
significance is given to covariance comparisons for employees that have
been with the company longer.

For the executive level employees, factoring in tenure results in a smaller


relationship between satisfaction and performance. This type of analysis can
be crucial in determining how performance can be improved or maintained
both for new hires and long tenured employees.

WeightedMean
An average, also known as an arithmetic mean, is the sum of a set of values
divided by the number of values in the set.

A weighted mean allows you to apply a weight, or relative significance to


each value when determining an average. Values with a higher value for
their weight are considered as more significant when compared to the other
values.

To calculate an average without applying a weight to the values, see Avg


(Average), page 117.

Syntax

WeightedMean<FactID>(Argument1, Weight)

Where:

l Argument1 is an attribute, fact, or metric representing a list of numbers


that are used to calculate an average.

l Weight is an attribute, fact, or metric representing a list of numbers to


define the weight of each value.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Copyright © 2023 All Rights Reserved 260


Fu n ct io n s Refer en ce

Example

You can calculate a weighted mean to apply greater significance to certain


values used to determine an average. For example, you can use the percent
growth of revenue as a way to define revenue values as more or less
significant for an average. The report shown below contains the attribute
Customer Region and the metrics Revenue, Percent Growth, Average
Revenue, and Weighted Mean Revenue. The report also includes the Year
attribute in the page-by to show results by year.

The expressions for the average and weighted mean calculations are as
follows:

l Average Revenue:

Avg(Revenue){Year}

l Weighted Mean Revenue:

WeightedMean(Revenue, [Percent Growth]){Year}

The weighted mean takes into account the weights of each revenue value.
For example, since Central's percent growth is greater than Northwest's
percent growth, and the weight in this example is the percent growth,
Central's revenue is given more significance in the weighted mean
calculation. This results in $2,229,195 for the Weighted Mean Revenue as
compared to $2,122,695 for the Average Revenue for all customer regions
for the given year.

Copyright © 2023 All Rights Reserved 261


Fu n ct io n s Refer en ce

Notice that while the Average Revenue and Weighted Mean Revenue are
applicable to a year in this example, the values are displayed for every
Customer Region row. One way to simplify the display of this information is
to include this data on a dossier. You can include the Average Revenue and
Weighted Mean Revenue results in text fields along with additional
visualizations of the data, as shown below.

WeightedStDev (Weighted Standard Deviation of a Sample)


The standard deviation is an indicator of how widely values in a group differ
from the mean (see StDev (Standard Deviation of a Sample), page 142). It is
useful for comparing different sets of values with a similar mean.

A weighted standard deviation allows you to apply a weight, or relative


significance to each value in a set of values. Values with a higher value for
their weight are considered as more significant to a sample as compared to
the other values in a sample.

WeightedStDev returns the weighted standard deviation of a population


based on a sample. This is a group-value function.

Syntax

WeightedStDev <Distinct, FactID>(Argument, Weight)

Where:

Copyright © 2023 All Rights Reserved 262


Fu n ct io n s Refer en ce

l Argument is an attribute, fact, or metric representing a list of numbers.

l Weight is an attribute, fact, or metric representing a list of numbers to define the


weight of each value.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

Expression

Where:

l w i : The weight of the ith value. Values with a higher value for their weight
are considered as more significant to a sample as compared to the other
values in a sample.

l N': The number of weights that are not equal to zero.

l x w : The weighted mean of the values.

Usage Notes

l In this function, arguments correspond to a population sample as opposed


to the entire population. For entire populations, see StDevP (Standard
Deviation of a Population), page 140.

Example

This example shows a report where the standard deviation and a weighted
standard deviation of the revenue are calculated. This calculation is based
on the assumption that the list of values supplied in the metric represents a
sample of the data for which you want to obtain the standard deviation. The
calculation is based on the revenue values for each state within a region and
calculated at the region level.

Copyright © 2023 All Rights Reserved 263


Fu n ct io n s Refer en ce

The report contains the attributes Customer Region and Customer State,
and the metrics Revenue, Standard Deviation, and Weighted Standard
Deviation.

The definition of the standard deviation metrics are as follows:

l Standard Deviation:

StDev(Revenue){[Customer Region], ~}

l Weighted Standard Deviation:

WeightedStDev(Revenue, Revenue) {[Customer Region] , ~ }

For this example, the revenue values are also used as the weights given
to each revenue value included in the standard deviation.

The report is shown below:

The weighted standard deviation also takes into account the weights of each
revenue value. For example, since Connecticut's revenue is greater than
Maine's revenue, and the weight in this example is the revenue value,
Connecticut's revenue is given more significance in the weighted standard

Copyright © 2023 All Rights Reserved 264


Fu n ct io n s Refer en ce

deviation calculation. This results in $957,689 for the standard deviation as


compared to $1,141,237 for the weighted standard deviation of Northeast
revenue.

Notice that while the standard deviation and weighted standard deviation are
applicable to a Customer Region in this example, the values are displayed
for every Customer State row. One way to simplify the display of this
information is to include this data on a dossier. You can include the standard
deviation and weighted standard deviation results in text fields along with
additional visualizations of the data, as shown below.

Pattern Functions
Sequential Pattern Matching (SPM) takes an input table, sorts it in a
specified sequence, then scans through the rows looking for a pattern
across rows, and then returns aggregate information based on the matching
rows.

PatternMatch
This function defines a transaction in terms of a Derived Attribute. One or
more attribute elements or metric values will be mapped to the same
transaction group (assign the same integer number) if matching with a given
pattern.

Copyright © 2023 All Rights Reserved 265


Fu n ct io n s Refer en ce

Syn t ax

PatternMatch<Breakby, SortBy>(ValueList, Pattern, maxNum)

Where:

ValueList is either be a list of attribute elements or metric values.

Pattern is a pattern for given input to be matched with. Such pattern is


defined using a regular expression or simply {%string} to match with any
string.

maxNum is the maximum number of elements allowed within the same


transaction group (assigned with the same integer number). "-1" value
indicates no limitation.

PatternMatchCorr
This function defines a transaction in terms of a Derived Attribute. Given
attribute elements or metric values are mapped to the same transaction
group only if input1 (ValueList1) matches with a pre-defined pattern and
input2 (ValueList2) qualifies on certain conditions.

Syn t ax

PatternMatchCorr<Breakby, SortBy>(ValueList1, Pattern,


ValueList2, maxPairDiff, maxDiff, maxNum)

Where:

l ValueList1/ValueList2 are either lists of attribute elements or metric


values.

l Pattern specifies a pattern for ValueList1 to be matched with. Such


pattern is defined using a regular expression or simply {%string} to match
with any string.

l maxPairDiff specifies the maximum difference allowed between the


neighbor elements within ValueList2 to be mapped to the same

Copyright © 2023 All Rights Reserved 266


Fu n ct io n s Refer en ce

transaction group (assign the same integer number). "-1" value indicates
no limitation.

l maxDiff specifies the maximum difference between the minimum and the
maximum elements within ValueList2 to be mapped to the same
transaction group (assign the same integer number). "-1" value indicates
no limitation.

l maxNum specifies the maximum number of elements allowed within the


same transaction group (assigned with the same integer number). "-1"
value indicates no limitation.

PatternMatchDiff
This function defines a transaction in terms of a Derived Attribute. One or
more given attribute elements or metric values are mapped to the same
transaction group (assign the same integer number) if certain conditions
(specified by parameters: maxPairDiff, maxDiff and maxNum) are met.

Syn t ax

PatternMatchDiff<Breakby, SortBy>(ValueList, maxPairDiff,


maxDiff, maxNum)

Where:

l ValueList can either be a list of attribute elements or metric values.

l maxPairDiff specifies the maximum difference allowed between the


neighbor elements within the ValueList to be mapped to the same
transaction group (assigned with the same transaction number). "-1" value
indicates no limitation.

l maxDiff specifies the maximum difference between the first and the last
elements within the ValueList to be mapped to the same transaction group
(assigned with the same transaction number). "-1" value indicates no
limitation.

Copyright © 2023 All Rights Reserved 267


Fu n ct io n s Refer en ce

l maxNum specifies the maximum number of elements allowed within the


same transaction group (assigned with the same integer number). "-1"
value indicates no limitation.

Rank and NTile Functions


Rank and NTile functions are used to qualify a list of values relative to the
other values. For example, out of the four quarters in a year, you want to
rank total revenue from one to four, with one being the top revenue for the
year.

Functions including Rank, Percentile, PercentRank, and


PercentRankRelative allow you to view the ranking of values such as a
simple integer list or various types of percentages.

NTile functions are used to group the values in an ordered list into one of
several buckets or NTiles. Each element in the list is assigned an integer
corresponding to the bucket to which it belongs. The various NTile functions
differ in how the buckets are defined. Some functions allow you to define the
number of buckets, others allow you to define the size of the buckets, and so
on.

NTile
NTile functions are used to group the values in an ordered list into one of
several buckets or NTiles. For the NTile function, the buckets are
calculated so that each bucket has exactly the same number of rows
assigned to it or at most one row more than the others (the exception is that
identical value rows are placed in the same bucket). For example, if you
have 100 rows in a partition and define an NTile function with four buckets,
25 rows will be assigned a value of 1, 25 rows will have value 2, and so on.
These buckets are referred to as equiheight buckets.

If the number of rows in the partition does not divide evenly into the number
of buckets, then, barring identical value rows, the number of rows assigned

Copyright © 2023 All Rights Reserved 268


Fu n ct io n s Refer en ce

per bucket will differ by one at most. The extra rows are added to buckets
using the calculations ceiling(1*(buckets/remainder)),...,
ceiling(remainder*(buckets/remainder)).

For example, if there are 103 distinct value rows in a partition which has an
NTile<Tiles=5>() function, the first 20 rows will be in the first bucket, the
next 21 in the second bucket, the next 20 in the third bucket, the next 21 in
the fourth bucket, and the final 21 in the fifth bucket. The calculations
ceiling(1*(5/3))=2, ceiling(2*(5/3))=4, and ceiling(3*
(5/3))=5 include one of the extra three rows each in the second, fourth,
and fifth buckets.

NTile distributes the values in the specified metric, sorted in either


ascending or descending order, over a user-defined number of buckets.
Each bucket has an equal number of elements (if possible). This is an OLAP
function.

Syntax

NTile <Ascending, Tiles, BreakBy> (Argument)

Where:

l Ascending is a TRUE/FALSE parameter that designates the organization


of data within the NTiles.

l BreakBy is the parameter that sets the attribute determining where the
calculation restarts.

l Tiles is a positive integer that designates the number of buckets or


NTiles.

l Argument is a metric representing a list of values to be distributed equally


(if possible) into n buckets.

Example

Example 1: If you define Tiles=4 for a metric that contains 20 values, the
function distributes the numbers as follows:

Copyright © 2023 All Rights Reserved 269


Fu n ct io n s Refer en ce

l Values 1 through 5 in bucket 1

l Values 6 through 10 in bucket 2

l Values 11 through 15 in bucket 3

l Values 16 through 20 in bucket 4

Example 2: This example shows a report where the customer states were
sorted based on revenue and then divided among a specified number of
buckets. The number of buckets is defined as 8. The report includes the
attribute Customer State and the metrics Total Revenue and NTile. The
NTile metric is a derived one, the syntax for which is as follows:

NTile<Tiles=8>([Total Revenue])

The resulting report divides the 48 states into 8 NTiles, each containing 6
elements (states). Within each band the data is sorted in ascending order by
the attribute Customer State. A portion of the report is displayed as follows.

Copyright © 2023 All Rights Reserved 270


Fu n ct io n s Refer en ce

NTileSize
NTileSize distributes the values in the specified metric, sorted in either
ascending or descending order, with the same number of elements in each
bucket. The number of elements in each bucket is user-defined. This is an
OLAP function.

Syntax

NTileSize <Ascending, BreakBy> (Argument, Size)

Where:

Copyright © 2023 All Rights Reserved 271


Fu n ct io n s Refer en ce

l Ascending is a TRUE/FALSE parameter that designates the organization


of data within the NTiles.

l BreakBy is the parameter that sets the attribute determining where the
calculation restarts.

l Argument is a metric representing a list of values to be distributed in


buckets.

l Size is a positive integer that designates the number of elements per


bucket.

Example

Example 1: If you define the Size as 2, the function returns buckets


containing two values each. If there are six values, values one and two go in
bucket 1, values three and four go in bucket 2, and values five and six go in
bucket 3.

Example 2: This example shows a report where the customer states are
sorted by revenue and then placed in buckets based on the number of
elements that can fit in a bucket. The number of elements per bucket size is
defined as 8. The report includes the attribute Customer State and the
metrics Total Revenue and NTileSize. The syntax for the NTileSize metric is
as follows:

NTileSize ([Total Revenue],8)

The resulting report divides the 48 states into 6 buckets each containing 8
elements (states). A portion of the resulting report displays as follows.

Copyright © 2023 All Rights Reserved 272


Fu n ct io n s Refer en ce

NTileValue
NTileValue distributes the values in the metric by value ranges over a
user-defined number of buckets, sorted in either ascending or descending
order. Each bucket is the same size in terms of the range of values
contained in the bucket, but the number of elements per bucket is not equal.
This is an OLAP function.

Syntax

NTileValue <Ascending, Segments, BreakBy> (Argument)

Where:

Copyright © 2023 All Rights Reserved 273


Fu n ct io n s Refer en ce

l Ascending is a TRUE/FALSE parameter that designates the organization


of data within the NTiles.

l Segments is a positive integer designating the number of buckets in which


the values are distributed.

l BreakBy is the parameter that sets the attribute determining where the
calculation restarts.

l Argument is a metric representing a list of values to be distributed into


buckets.

Example

Example 1: If you define the Segments=4, and the minimum value in the
range is 5 and the maximum is 105, the bucket distribution is as follows,
where x is the value:

l 5 £ x < 30 in bucket 1

l 30 £ x < 55 in bucket 2

l 55 £ x < 80 in bucket 3

l 80 £ x £ 105 in bucket 4

Example 2: This example shows a report where the customer states are
sorted based on revenue and then placed in buckets based on the value
range to which they belong. The number of buckets (segments) is defined as
4. The range of values is divided by the number of buckets and the result is
used to define four value ranges into which all the values fall. The report
includes the attribute Customer State and the metrics Total Revenue and
NTileValue. The syntax for the NTileValue metric is as follows:

NTileValue<Segments=4>([Total Revenue])

The resulting report displays the 48 states distributed across 4 buckets.


Notice that the number of elements in each bucket is not equal as more
values fall into one range than another. A portion of the resulting report is
displayed as follows.

Copyright © 2023 All Rights Reserved 274


Fu n ct io n s Refer en ce

Exam ple 3: Histogram

The reports and components used in this example are available in the
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial\Public Objects\Reports\MicroStrate
gy Platform Capabilities\Advanced Analytics\Statistics an
d Forecasting\Histogram

How are My Customers Distributed (Classified) Based on Sales Data?

You are interested in finding out how your customers are distributed based
on their contributions to sales data. This example segments customers into
10 separate groups, with each group representing the customers within a
10% increment of sales. For example, the first segment includes the
customers who spend in the lowest 10% of the sales, while the final, tenth
segment includes the customers who spend in the top 10% of the sales.

This example uses the following concepts:

Copyright © 2023 All Rights Reserved 275


Fu n ct io n s Refer en ce

l Analytical functions: NTileValue

l Custom group

NTileValue distributes values into buckets based on minimum and maximum


values. These tiles are assigned an integer and the contents of each bucket
denoted accordingly. For example, all customers that fall in the first bucket
are assigned a 1, all customers in the second bucket are assigned a 2, and
so on. This function is computed by Intelligence Server. The metric using
NTileValue is then used to create a dynamic classification of Customers
using a custom group.

To create a general solution that can be used by different users, use object
prompts (see instructions below).

Create the following object prompts:

l Choose a base fact. This object prompt asks the user to select a fact:
Revenue, Profit, or Units Sold.

l Choose a sample set level. This object prompt asks the user to select an
attribute: Customer, Item, or Day.

Copyright © 2023 All Rights Reserved 276


Fu n ct io n s Refer en ce

Once you have identified the basic fact and attribute to analyze, you can
start building other objects. Take the following steps:

1. Create a metric defined as follows:

Sample Set Metric = Sum(?[Choose a base fact]){~, ?


[Choose a sample set level]}

2. To put the value in the proper buckets (tiles), create another metric
defined as:

Decile By Value = NTileValue<Segments=10> ([Sample Set


Metric])

3. Create a dynamic classification of the subject attribute (Customers,


Item, or Day) by building a custom group using banding. Use the metric
Decile By Value, the banding type "band count" and set the band count
to 10, starting at 1 and stopping at 10.

Copyright © 2023 All Rights Reserved 277


Fu n ct io n s Refer en ce

4. Choose to show only individual items within this element since the
objective is to build a graph (histogram) for this custom group.

5. Count the number of elements in the new classification to display a


histogram. To do this, create a dummy metric defined as follows:
Count of Samples = Count(1){~}

Copyright © 2023 All Rights Reserved 278


Fu n ct io n s Refer en ce

6. Since there is no column to perform the count, define the metric so that
the database can calculate how many attribute elements are in each
custom group element.

7. Add the Decile by Value custom group to the row axis, and the Count of
Samples metric to the column axis.

8. Execute the report with attribute Customer and fact Revenue, and the
Decile Histogram, in Grid mode, displays as follows:

The same report, in graph mode, appears as follows:

Copyright © 2023 All Rights Reserved 279


Fu n ct io n s Refer en ce

The SQL generated for the Decile by Histogram is as follows:

Pass0 - Duration: 0:00:00.25


select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[TOT_DOLLAR_SALES] AS WJXBFS1
from [CUSTOMER_SLS] a11
Pass1 - Duration: 0:00:00.09
create table ZZT1Y02011CMQ000 (
CUSTOMER_ID SHORT,
DA56 LONG)
Pass2 - Duration: 0:00:00.00
[An Analytical SQL]
Pass3 - Duration: 0:01:13.64
insert into ZZT1Y02011CMQ000 values (1499, 1)
Pass4 - Duration: 0:00:00.32
select a11.[DA56] AS DA56,
count(1.0) AS WJXBFS1
from [ZZT1Y02011CMQ000] a11
group by a11.[DA56]
Pass5 - Duration: 0:00:00.03
drop table ZZT1Y02011CMQ000

l Pass0 computes the revenue for each Customer using the Sample Set
Metric.

l The next three passes (Pass1, Pass2, and Pass3) prepare the dynamic
classification of Customer for the custom group. This series of SQL passes
essentially builds a dynamic lookup table for the classification that is
requested. The column DA stands for Dynamic Attribute. The Intelligence
Server computes the NTileValue function. This is indicated by [An
Analytical SQL] in Pass3. The value is then inserted, with the new
classification, into the dynamic lookup table for the custom group.

l Pass4 calculates the number of customers that belong to each custom


group element.

l Pass5 drops the temporary table.

Copyright © 2023 All Rights Reserved 280


Fu n ct io n s Refer en ce

NTileValueSize
NTileValueSize distributes the values in the metric across buckets based
on a user-specified value range, sorted in either ascending or descending
order. This is an OLAP function.

Syntax

NTileValueSize <Ascending, BreakBy> (Argument, Size)

Where:

l Ascending is a TRUE/FALSE parameter that designates the organization


of data within the NTiles.

l BreakBy is the parameter that sets the attribute determining where the
calculation restarts.

l Argument is a metric representing the list of values to be distributed


across buckets.

l Size is a real number designating the size of the range of values for each
bucket.

Example

Example 1: If you define size as 1000 and your range of values begins at
1200, the first bucket contains values 1200 through 2199, the second bucket
contains values 2200 through 3199, and so on until every value is in a
bucket. It does not matter how many values are in each bucket; it only
matters that their value is within the bucket range.

Example 2: This example shows a report where the customer states were
sorted based upon revenue and then placed in buckets based upon the value
range to which they belong. The value range is defined as 100,000.
Beginning at the lowest metric value, in this case 18,654, the first bucket
contains values from 18,654 to 118,653, the next bucket ranges from
118,654 to 218,653, and so on until all values are in buckets. The highest

Copyright © 2023 All Rights Reserved 281


Fu n ct io n s Refer en ce

value in the report is 1,839,238, which falls into bucket 19 and is the only
value in that range.

The report includes the attribute Customer State and the metrics Total
Revenue and NTileValueSize. The syntax for the NTileValueSize metric is
as follows:

NTileValueSize ([Total Revenue], 100000)

A portion of the resulting report is displayed as follows.

Percentile
Returns the n th percentile of values in a given range. This function can be
used to establish thresholds indicating, for example, which states have
revenue above the 75th percentile for their region. This is a group-value
function.

Syntax

Percentile <Ascending, FactID> (Argument, Percent)

Copyright © 2023 All Rights Reserved 282


Fu n ct io n s Refer en ce

Where:

l Ascending is a TRUE/FALSE parameter that indicates the organization of


the data.

l Argument is an attribute, fact or metric representing a list of numbers.

l Percent is the decimal value of the percent for which you want to use as
a threshold.

Example

Example 1: If you have an argument containing the values 1, 2, 3, and 4 and


you want to find the threshold of the 3oth percentile, the syntax is as follows:

Percentile ({1, 2, 3, 4}, 0.3) = 1.9

1.9 is the level of the 30th percentile. All values above 1.9 are greater than
the 30th percentile.

Example 2: This example shows a report where only states with Total
Revenue greater than the threshold for the 75th percentile in its region are
displayed. The report contains the attributes Customer Region and
Customer State, and the metrics Total Revenue and Percentile. A view filter
is then applied to the report so that it only displays states where Total
Revenue is greater than Percentile.

The syntax for the Percentile metric is as follows:

Percentile([Total Revenue], .75){[Customer Region]}

Copyright © 2023 All Rights Reserved 283


Fu n ct io n s Refer en ce

PercentRank
This function is used to display the ranking of values as a percentage. For
example you can rank profit for a particular region based on the profit for all
regions.

The calculation can restart based on attributes identified in the parameter


settings. This is an OLAP function.

You can also rank values in the following ways:

l You use the Rank function (see Rank , page 289) to rank values as an
integer value. For example you can rank profit for five categories from 1 to
5.

l You use the PercentRankRelative function (see PercentRankRelative,


page 286) to rank values as a percentage, with the ranking based on
another data set. For example you can rank profit for the current year
based on last year's profit.

Syntax

PercentRank <inclusive, BreakBy> (Argument)

Where:

Copyright © 2023 All Rights Reserved 284


Fu n ct io n s Refer en ce

l Argument is a fact or metric representing a list of numbers that are to be


ranked.

l inclusive is a TRUE/FALSE parameter that indicates whether the rank is


inclusive or exclusive:

l TRUE (default): The percent rank is in a range from 0 to 1 inclusive. This


means that 0% and 100% are included.

l FALSE: The percent ranks is in a range from 0 to 1 exclusive. This


means that 0% and 100% are excluded.

l BreakBy is the parameter that designates where the calculation should


restart.

Example

The example report shown below displays revenue information across


regions for a given quarter. You can use PercentRank to return the rank of
revenue for each region during a given quarter.

The definition for the Percent Rank Revenue metric in this example is:

PercentRank<BreakBy={Quarter}>(Revenue)

The Percent Rank Revenue metric in the report shown above provides the
rank of each revenue value. You can see that the highest value in the
Northeast region is displayed as 100% while the lowest value in the
Northwest region is displayed as 0%.

Copyright © 2023 All Rights Reserved 285


Fu n ct io n s Refer en ce

This report also includes a metric that uses the PercentRankRelative


function, ranking the revenue based on last quarter's revenue. For
information on PercentRankRelative and an explanation of these
results, see PercentRankRelative, page 286.

PercentRankRelative
This function is used to display the ranking of values as a percentage, with
the ranking based on a secondary data set. For example you can rank the
current year's profit for a particular region based on (relative to) the profit
from the previous year.

The calculation can restart based on attributes identified in the parameter


settings. This is an OLAP function.

You can also rank values in the following ways:

l The Rank function (see Rank , page 289) ranks values as an integer value.
For example, you can rank profit for five categories from 1 to 5.

l The PercentRank function (see PercentRank , page 284) ranks values as


a percentage based on those values as the data set. For example, you can
rank profit for a particular region based on the profit for all regions.

Syntax

PercentRankRelative <inclusive, rankOutliers, significance,


truncate, BreakBy> (Argument, Rank)

Where:

l Argument is a fact or metric representing a list of numbers that are to be


ranked.

l Rank is a fact or metric representing a list of numbers that are used to


determine the rank of the values provided with Argument. The values for
Rank should be within the same range as the values of Argument to
provide a relevant ranking. For example, using profit values to rank
revenue would rarely result in relevant results, as profit is likely to have a

Copyright © 2023 All Rights Reserved 286


Fu n ct io n s Refer en ce

different range of values than Revenue. However, using last year's profit
to rank this year's profit can provide relevant results as the profits
between last year and this year are more likely to be in the same range of
values.

l inclusive is a TRUE/FALSE parameter that indicates whether the rank is


inclusive or exclusive:

l TRUE (default): The percent rank is in a range from 0 to 1 inclusive. This


means that 0% and 100% are included.

l FALSE: The percent rank is in a range from 0 to 1 exclusive. This means


that 0% and 100% are excluded.

l rankOutliers is a TRUE/FALSE parameter that indicates whether outlier


values are included in the calculation:

l TRUE: Values from Rank that are outside of the range of values from
Argument are included in the ranking. This often results in showing
values such as 100% or 0%.

l FALSE (default): Values from Rank that are outside of the range of
values from Argument are not included in the ranking. The results are
left blank rather than showing a percentage.

l significance (default is 3) determines the number of digits that are


used to perform each calculation. You can provide any integer value from
1 to 9 for this parameter.

l truncate is a TRUE/FALSE parameter that indicates whether the final


result is rounded or truncated:

l TRUE (default): The final result is truncated, based on the significance


applied to the calculation. For example, using the default of
significance=3, the fourth digit is dropped and is not used to round
the third digit.

Copyright © 2023 All Rights Reserved 287


Fu n ct io n s Refer en ce

l FALSE: The final result is rounded, based on the significance applied to


the calculation. For example, using the default of significance=3, the
fourth digit is used to round the third digit.

l BreakBy is the parameter that designates where the calculation should


restart.

Example

The example report shown below displays revenue information across


regions for a given quarter. You can use PercentRankRelative to return
the rank of revenue for each region during a given quarter, relative to last
quarter's revenue.

The definition for the Percent Rank Revenue metric in this example is:

PercentRankRelative<BreakBy={Quarter}>(Revenue, [Last Quarter's


Revenue])

The Percent Rank Relative Revenue metric in the report shown above
provides the rank of each revenue value. The highest value in the Northeast
region displays no data because last quarter's revenue is $797,627, which is
greater than any revenue value for this quarter and thus outside of the range
of values. Since the default for the function is to not rank outlier values, no
data is displayed. If you modify the rankOutlier parameter to be
rankOutlier=TRUE, then data is returned for this ranking as shown in the
report below.

Copyright © 2023 All Rights Reserved 288


Fu n ct io n s Refer en ce

This report also includes a metric that uses the PercentRank function,
ranking the revenue based on its own values. For information on
PercentRank and an explanation of these results, see PercentRank , page
284.

Rank
This function is used to display the ranking of values in a list relative to the
other values. The calculation can restart based on attributes identified in the
parameter settings. This is an OLAP function.

Unless the defaults are changed, the function ranks the values in ascending
order by the value of the metric, and the rank is an integer.

Syntax

Rank <ASC, ByValue, BreakBy, NullInclude> (Argument)

Where:

l Argument is a fact or metric representing a list numbers.

l ASC is a TRUE/FALSE parameter that indicates the order of ranking (1 is


the lowest or highest value).

l ByValue is a TRUE/FALSE parameter that indicates whether the ranking is


done by integer values (1, 2, 3, 4) or by percentage (10%, 50%, 75%,
100%).

l BreakBy is the parameter that designates where the calculation should


restart.

Copyright © 2023 All Rights Reserved 289


Fu n ct io n s Refer en ce

l NullInclude is a parameter that determines how NULL values are


included in the rank calculation.

The NullInclude parameter only affects the rank of NULL values if the
Rank function is performed by the MicroStrategy Analytical Engine. The
Rank function is performed by the Analytical Engine for smart metrics,
derived metrics, and other metric scenarios. To determine whether the
Rank function for a metric is performed by the Analytical Engine, view the
SQL statement for the report. If the metric is listed in the Analytical Engine
calculation steps, this verifies that the Rank function is performed by the
Analytical Engine.

If the Rank function is performed on a database, the NullInclude


parameter is ignored and NULL values are included in the rank calculation
based on the database standards.

For Rank functions that are performed by the Analytical Engine, you have
the following options for this parameter:

l 1: If you define NullInclude=1, NULL values are given a rank value


equal to the number of other rank values, plus one. For example, the
rank of the Profit metric in the report below ranks four separate profit
values.

There is one NULL value, which is given the rank of 4. The Rank (Profit)
metric in this example uses an ascending rank. If you define the metric
with a descending rank, the other rank values change but the rank value
for any NULL values remains the same. This is shown in the report

Copyright © 2023 All Rights Reserved 290


Fu n ct io n s Refer en ce

below.

l -1: If you define NullInclude=-1, NULL values are given the rank
value of one. For example, the reports shown below both define the
Rank (Profit) metric with NullInclude=-1. The report on the left uses
an ascending rank, while the report on the right uses a descending rank.

As shown in the reports above, the NULL values for both reports are
ranked with the value of one.

l 0 (default): If you define NullInclude=0, NULL values are included in


the rank calculation based on the NULL value handling defined using the
Null checking for Analytical Engine VLDB property. For information on
VLDB properties, including steps to access and modify them for various
MicroStrategy objects, see the System Administration Guide :

If you define the Null checking for Analytical Engine property as True,
NULL values are treated as zero values in the rank calculation. For
example, the report shown below ranks the NULL values with a rank of
two, because zero is greater than -10 and less than 40.

Copyright © 2023 All Rights Reserved 291


Fu n ct io n s Refer en ce

If you define the Null checking for Analytical Engine property as False,
NULL values are treated as NULL values, which means NULL values are
also displayed for the rank values. For example, the report shown below
displays the NULL values as NULL in the rank.

Example

This example report displays customer states ranked by revenue within their
regions. There are two metrics, one that ranks by value (default) and the
other that ranks using a percentage. In order to have the state with the
highest revenue in each region ranked as 1 in the Rank by Value metric, the
Rank by Value ranking is descending. In order to have the largest number
ranked at 100% in the Rank by Percent metric, the ranking is ascending
(default).

The report includes the attributes Customer Region, Customer State, the
metric Total Revenue (defined as Sum(Revenue)), and the two ranking
metrics. The syntax for the metrics is as follows:

Rank by Value:

Rank<ASC=False,ByValue=True, BreakBy={[Customer Region]}>([Total


Revenue])

Rank by Percent:

Copyright © 2023 All Rights Reserved 292


Fu n ct io n s Refer en ce

Rank<ASC=True,ByValue=False BreakBy={[Customer Region]}>([Total


Revenue])

The resulting report is displayed as follows.

String Functions
String functions perform various actions that modify the characters returned
for a string of characters. While string functions can be used to create
metrics, a more common use case for these functions is in the creation of
attribute forms. For example, these functions can aid in the creation of
attribute forms by combining multiple columns of information, capitalizing
the first letter of a column, removing or returning select characters of a
column, and so on. For information on creating attributes and attribute
forms, see the Project Design Help.

The MicroStrategy Analytical Engine does not calculate string functions;


they are processed by the database. For information on which string
functions are supported for your specific database, see Appendix A,
MicroStrategy and Database Support for Functions, and search in the
section corresponding to your database. String functions for which your
database does not include SQL syntax support cannot be calculated in your
environment.

Copyright © 2023 All Rights Reserved 293


Fu n ct io n s Refer en ce

This section of the document includes information and examples on the data
returned by the function.

BeginsWith
Returns 1 if a text string begins with a specified text pattern. If the text string
does not begin with the pattern, the function returns 0.

For the definition and syntax of the Begins with comparison operator, see
Begins With, page 326.

Syntax

BeginsWith(String, Pattern)

Where:

l String is the string that is being searched. You can use facts, metrics,
columns, or string values.

l Pattern is the string that is being searched for at the beginning of the
values from String. You can use facts, metrics, columns, or string
values.

The text pattern comparison may or may not be case sensitive depending on
the database implementation.

Example

BeginsWith(Region@DESC, "North")

Returns 1 for Regions that start with North, such as Northeast and
Northwest.

Char (Convert ASCII Code to a Character)


The Char function converts a decimal ASCII code into its associated
character. This function supports returning any of the standard 128
characters assigned an ASCII code.

Copyright © 2023 All Rights Reserved 294


Fu n ct io n s Refer en ce

Syntax

Char(Argument)

Where:

Argument is a fact, metric, column, or constant value that provides an


ASCII code in ASCII decimal format. Any value provided outside the range of
0 to 127 causes the Char function to return a single question mark (?)
character. Any other invalid input, such as character strings, causes the
Char function to return null.

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

Example

Char(65)

This example returns A.

Concat (Concatenate)
The Concat function combines two or more input strings into one
continuous string and returns the result. For example, concatenating the two
strings "Micro" and "Strategy" would result in the single string
"MicroStrategy". Concat is often used to combine related values, such as a
first and last name.

Syntax

Concat(Argument1, Argument2,..., ArgumentN)

Where:

Argument1,..., ArgumentN are facts, metrics, columns, or string


values.

Copyright © 2023 All Rights Reserved 295


Fu n ct io n s Refer en ce

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

Example

The Concat function can help to create attribute forms that are a
combination of multiple columns in database tables. For example, an LU_
CUSTOMER table includes two columns: CUST_FIRST_NAME and CUST_
LAST_NAME. You can create a single attribute form that combines these two
columns as described below.

Concat([CUST_FIRST_NAME], [CUST_LAST_NAME])

The input from the first column is concatenated with the input from the
second column, to display information such as JohnDoe and JaneDoe for the
attribute form.

For scenarios such as the one described above, you can use the
ConcatBlank function (see ConcatBlank (Concatenate Plus Blank Space),
page 297 below) to concatenate the strings and include a space between
the two strings. This can result in attribute forms that are easier to read. For
example, rather than displaying JohnDoe, the attribute form would display
John Doe.

For an additional example of using the Concat function, see the example
section for the function InitCap (Initial Capitalization), page 299.

ConcatAgg (Concatenate Plus Delimiter)


The ConcatAgg function takes all of the content from a single input and
concatenates the content as a single string. By default, each string of
characters that is concatenated is separated by a comma. You can define
the delimiter.

Syntax

ConcatAgg<Delimiter, FactID

Copyright © 2023 All Rights Reserved 296


Fu n ct io n s Refer en ce

Where:

l Argument is facts, metrics, columns, or string values.

l Delimiter is a parameter that determines the characters used to


separate each concatenated value. By default, a comma is used.

l FactID is a parameter that forces a calculation to take place on a fact


table that contains the selected fact.

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

Example

The ConcatAggBlank function can help to create attribute forms that are a
combination of multiple rows in database tables. For example, an LU_
CUSTOMER table includes a column CUST_LAST_NAME. You can create a
single attribute form that combines all the values (rows) for CUST_LAST_
NAME into a single attribute form:

ConcatAgg([CUST_LAST_NAME])

Each last name is concatenated, separating each last name with a comma
by default.

ConcatBlank (Concatenate Plus Blank Space)


The ConcatBlank function concatenates two or more input strings into one
continuous string, inserting a blank space between each string. This function
can be used to combine related values that are logically separated by
spaces. For example, concatenating the two strings "Business" and
"Intelligence" would result in the single string "Business Intelligence".

Syntax

ConcatBlank (Argument1, Argument2,..., ArgumentN)

Where:

Copyright © 2023 All Rights Reserved 297


Fu n ct io n s Refer en ce

Argument1,..., ArgumentN are facts, metrics, columns, or string


values.

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

Example

The ConcatBlank function can help to create attribute forms that are a
combination of multiple columns in database tables. For example, an LU_
CUSTOMER table includes two columns: CUST_FIRST_NAME and CUST_
LAST_NAME. You can create a single attribute form that combines these two
columns as described below.

ConcatBlank([CUST_FIRST_NAME], [CUST_LAST_NAME])

The input from the first column is concatenated with the input from the
second column, and an additional space is included between the two inputs.
This displays information such as John Doe and Jane Doe for the attribute
form.

For an additional example of using the ConcatBlank function, see the


example section for the function InitCap (Initial Capitalization), page 299.

EndsWith
Returns 1 if a text string ends with a specified text pattern. If the text string
does not end with the pattern, the function returns 0.

For the definition and syntax of the Ends With comparison operator, see
Ends With, page 328.

Syntax

EndsWith(String, Pattern)

Where:

Copyright © 2023 All Rights Reserved 298


Fu n ct io n s Refer en ce

l String is the string that is being searched. You can use facts, metrics,
columns, or string values.

l Pattern is the string that is being searched for at the end of the values
from String. You can use facts, metrics, columns, or string values.

Example

EndsWith ([Unit Price], ".99")

Returns 1 for prices that end in .99, such as 10.99, 11.99, and so on.

If String is an attribute form, the EndsWith function can only be used to create
attributes, not metrics. If you use an expression similar to the one below to create a
new metric, you receive an error message.

EndsWith(Employee@[Last Name], "son")

InitCap (Initial Capitalization)


The InitCap function returns a string in which the first letter of the input
string is capitalized. All other letters appear in lower case. This can help to
fix capitalization errors in information that is displayed for attribute forms,
metrics, and other objects.

To capitalize the first letter of every word in a string, see TitleCap (Title
Capitalization), page 314.

Syntax

InitCap(Argument)

Where:

Argument is a metric, column, or string value representing the text string.

For information on the syntax used in your specific database,see Appendix


A, MicroStrategy and Database Support for Functions and see the section
that corresponds to your database.

Example

Copyright © 2023 All Rights Reserved 299


Fu n ct io n s Refer en ce

The InitCap function can be used to fix capitalization errors for information
that is displayed for attribute forms. For example, an LU_CUSTOMER table
includes two columns: CUST_FIRST_NAME and CUST_LAST_NAME. To
ensure that the first letter of the last name is capitalized you create an
attribute form with the following definition.

InitCap([CUST_LAST_NAME])

The input from the column is modified so that the first character is
capitalized and all other characters are lowercase. For example, if the
column included information such as jackson, sMITh, and Hughes, these
would be displayed as Jackson, Smith, and Hughes respectively.

Be aware that this function could potentially return undesired results in


certain scenarios. Using the scenario described above, consider the name
McCoy. Using the InitCap function, this would be displayed as Mccoy.

Another way to use this function would be to create an attribute form that
combined the first letter of someone's first name with the person's full last
name. The InitCap function could be used to ensure that the first letter of
the first name was capitalized. An attribute form of this type would require
the use of the functions InitCap, ConcatBlank, Concat, and LeftStr.
The definition of such an attribute form is shown below:

ConcatBlank(Concat(LeftStr(InitCap([CUST_FIRST_NAME]), 1), "."),


[CUST_LAST_NAME])

An attribute form using a definition such as the one listed above would
display names such as J. Doe, M. Smith, and L. Martinez. The InitCap
function ensures that the first letter of the first name is capitalized.

LastPosition (Last Position of Substring)


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

Copyright © 2023 All Rights Reserved 300


Fu n ct io n s Refer en ce

To find the first occurrence of a series of characters in a string, see Position


(Position of Substring), page 307.

Syntax

LastPosition (Argument1, Argument2)

Where:

l Argument1 is the string in which to search for Argument2.

l Argument2 is the substring to search for.

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

LeftStr (Left String Selection)


The LeftStr function returns a substring taken as a specified number of
characters from the left of the input string. For example, if the specified
length is five, LeftStr would return the string "Micro" from the original
string "MicroStrategy". LeftStr is useful for abbreviations or length
reduction when the entire input string is not required.

Syntax

LeftStr (Argument, Length)

Where:

l Argument is a metric, fact, column, or string value representing the text


string(s).

l Length is an integer indicating the number of characters, starting from the


far left position of the string, to be returned.

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

Example

Copyright © 2023 All Rights Reserved 301


Fu n ct io n s Refer en ce

The LeftStr function can be used to create attribute forms that use
abbreviations. This can help reduce the length for attribute forms that may
have long descriptions.

For example, an LU_CUSTOMER table includes two columns: CUST_FIRST_


NAME and CUST_LAST_NAME. You create attribute forms for the customer
first and last names. You also create an attribute form that displays only the
first letter of the first name. This attribute form can be used when the full
first name does not need to be displayed. The definition of such an attribute
form is shown below:

LeftStr([CUST_FIRST_NAME], 1)

The integer value of 1 causes the LeftStr function to only display the first
character at the far left position for all inputs from the CUST_FIRST_NAME
column.

For an additional example of using the LeftStr function, see the example
section for the function InitCap (Initial Capitalization), page 299.

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 Appendix
A, MicroStrategy and Database Support for Functions and see the section
that corresponds to your database.

Example

Copyright © 2023 All Rights Reserved 302


Fu n ct io n s Refer en ce

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, page 415.

Lower (Lower Case)


The Lower function returns a string in which all alphabetic characters in an
input string are displayed as lower case. For example, using the Lower
function on the string "MicroStrategy" would return the string
"microstrategy".

Lower may be used to help standardize the display of information and make
the information more readable.

Syntax

Lower(Argument)

Where:

Argument is a metric, column, or string value representing the text string


(s).

Copyright © 2023 All Rights Reserved 303


Fu n ct io n s Refer en ce

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

Example

The Lower function can be used to display information in all lower case for
attribute forms. For example, an LU_CUSTOMER table includes an ADDRESS
column. You can create an attribute form to display all characters for a
customer's address in lower case. The definition of such an attribute form is
shown below:

Lower([ADDRESS])

An attribute form using a definition such as the one listed above would take
input addresses such as 10 Main Street, 350 West Elm Avenue, and 4400
Spring Road and display them as 10 main street, 350 west elm avenue, and
4400 spring road, respectively.

LTrim (Left Trim)


The LTrim function returns a string in which any leading blank spaces on
the left side of the input string have been removed. For example, using the
LTrim function on the string " MicroStrategy" would return the string
"MicroStrategy".

The LTrim function helps to remove blank spaces that may have been
caused by errors in data entry. Removing these spaces helps standardize
the display of information and makes the information more readable.

Syntax

LTrim(Argument)

Where:

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

Copyright © 2023 All Rights Reserved 304


Fu n ct io n s Refer en ce

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

Example

An LU_CUSTOMER table includes an ADDRESS column. You can create an


attribute form to remove any leading blank spaces from the addresses. The
definition of such an attribute form is shown below:

LTrim([ADDRESS])

Any leading blank spaces included for addresses are removed from the
display for the attribute form.

To remove both leading and trailing blank spaces, use the Trim function
(Trim, page 316).

Match
The Match function uses regular expressions to search a string for a pattern
of characters and returns any matches that are found.

Syntax

Match <Group=0,Instance=1>(Argument, Find)

Where:

l Argument is a metric, fact, column, or string representing the text strings


that are searched for matches.

l Find is a metric, fact, column, or string that provides a regular expression


used to searched the strings returned by Argument. The regular
expressions supported by this function conform to the standards of the
International Components for Unicode. For information about these
regular expression standards and syntax, see http://userguide.icu-
project.org/strings/regexp.

Copyright © 2023 All Rights Reserved 305


Fu n ct io n s Refer en ce

l Group is a parameter that determines which group within the regular


expression is returned. The groups in a regular expression are each set of
characters enclosed by parentheses () and are ordered left to right. By
default, the Group parameter is defined as 0 and the entire string that is
matched is returned. If you define Group as 1, only the first group from the
left of the regular expression is returned. If you define Group to a value
greater than the number of groups in the regular expression, no results are
returned. For example if there is one group but Group is defined as 2, no
results are returned.

l Instance is a parameter that determines which instance of the matching


results are returned. By default, Instance is defined as 1 and the first
match is returned. If you define Instance to a value greater than the
number of matching results, no results are returned. For example if there
are two matches but Instance is defined as 3, no results are returned.

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

Example

Consider the string of text "Telephone: 703-555-1234, Fax: 704-555-6789".


You can search for and return various parts of the telephone numbers in this
string using regular expressions. The regular expression (\d+)[-\b]
(\d+)[-\b](\d+) breaks up the three sets of digits in a phone number
into separate groups, which can be returned using the Match function.

See http://userguide.icu-project.org/strings/regexp for information on the


regular expression standards and syntax.

For example:

l Match("Telephone: 703-555-1234, Fax: 704-555-6789", "(\d+)[-\b]


(\d+)[-\b](\d+)")

By default this returns the entire string that is the first match, which is 703-555-1234.

Copyright © 2023 All Rights Reserved 306


Fu n ct io n s Refer en ce

l Match<Group=1>("Telephone: 703-555-1234, Fax: 704-555-6789", "


(\d+)[-\b](\d+)[-\b](\d+)")

This returns the first group (the first search criteria in parentheses) from the first
occurrence, which is 703.

l Match<Instance=2, Group=3>("Telephone: 703-555-1234, Fax: 704-


555-6789", "(\d+)[-\b](\d+)[-\b](\d+)")

This returns the third group (the third search criteria in parentheses) from the second
occurrence, which is 6789.

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), page 300.

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:

l Argument1 is the substring to search for.

l Argument2 is the string in which to search for Argument1.

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

Example

Copyright © 2023 All Rights Reserved 307


Fu n ct io n s Refer en ce

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.

RepeatStr (Repeat String)


The RepeatStr function returns a character or string of characters the
specified number of times.

Syntax

RepeatStr(String, Times)

Where:

l String is a metric, fact, column, or string of characters representing the


characters to be repeated.

l Times is a metric, fact, column, or constant value that specifies how many
times to repeat the string of characters. A common practice is to type a
constant value.

Example

RepeatStr("Hello ", 3)

This would return the string of characters "Hello Hello Hello ".

Replace
The Replace function searches a string for a pattern of characters and
replaces each instance of those characters with the new characters you
specify. The resulting string with all instances replaced is returned.

Copyright © 2023 All Rights Reserved 308


Fu n ct io n s Refer en ce

Syntax

Replace(Argument, Find, Replace)

Where:

l Argument is a metric, fact, column, or string representing the text strings


that are searched.

l Find is a metric, fact, column, or string representing the text strings that
are searched for within the strings returned by Argument.

l Replace is a metric, fact, column, or string representing the text


strings that are used to replace any instances of the string from Find
that are included in the strings returned by Argument.

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

RightStr (Right String Selection)


The RightStr function returns a substring taken as a specified number of
characters from the right of the input string. For example, the first eight
characters from the right of the string "MicroStrategy" would be "Strategy".

RightStr can be used to create attribute forms that display only part of the
information available. This can be helpful when some information needs to
be hidden for security purposes, as in the credit card example below.

Syntax

RightStr (Argument, Length)

Where:

l Argument is a metric, fact, column, or string representing the text string


(s).

l Length is an integer indicating the number of characters to be returned.

Copyright © 2023 All Rights Reserved 309


Fu n ct io n s Refer en ce

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

Example

An LU_CUSTOMER table includes a CREDIT_CARD_NUMBER column that


contains credit card numbers for online customers. You create attribute
forms to display only the last four digits of the customers' credit card
numbers. The definition of such an attribute form is shown below:

RightStr([CREDIT_CARD_NUMBER], 4)

The integer value of 4 causes the RightStr function to only display the last
four characters from the CREDIT_CARD_NUMBER column.

You could also combine this functionality with the Concat function to
display Xs or other characters to represent the digits for the credit card that
are not displayed.

Concat("XXXX-XXXX-XXXX-", RightStr([CREDIT_CARD_NUMBER], 4))

This definition would modify the display of a credit card number from 1111-
2222-3333-4444 to be displayed as XXXX-XXXX-XXXX-4444.

RTrim (Right Trim)


The RTrim function returns a string in which blank spaces on the right side
of the input string have been removed. For example, using the RTrim
function on the string "MicroStrategy " would return the string
"MicroStrategy".

RTrim helps to remove trailing blank spaces, which may have been caused
by errors in data entry. Removing these spaces helps standardize the
display of information and makes the information more readable.

Syntax

RTrim(Argument)

Where:

Copyright © 2023 All Rights Reserved 310


Fu n ct io n s Refer en ce

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

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

Example

An LU_CUSTOMER table includes an ADDRESS column. You can create an


attribute form to remove any trailing blank spaces from the addresses. The
definition of such an attribute form is shown below:

RTrim([ADDRESS])

Any trailing blank spaces included in the addresses are removed from the
display for the attribute form.

To remove both leading and trailing blank spaces, use the Trim function
(Trim, page 316).

Split
The Split function searches a string, separates the contents into groups of
characters based on a delimiter, and returns the string of characters
requested. For example, you can search a string of characters that
separates values with commas, and return the characters after the first
comma. Searching the string "red, yellow, green" and selecting to return the
second set of characters based on a comma as the delimiter returns "yellow
".

Syntax

Split<SeparatorRegex=False>(String, Delimiter, Index)

Where:

l String is a metric, fact, column, or string representing the text strings


that are searched.

Copyright © 2023 All Rights Reserved 311


Fu n ct io n s Refer en ce

l Delimiter is a metric, fact, column, or string that determines the


characters used to separate each concatenated value. A common practice
is to provide a constant text value for the delimiter. Typing "," uses a
comma as the delimiter.

You can also choose to use regular expressions to define the delimiter
characters. For information on supporting regular expressions, see the
SeparatorRegex parameter described below.

If the delimiter character is not found in the string of characters, one of two
resolutions can occur:

l If you define Index as 1, then the entire string of characters is returned.

l If you define Index as any value other than 1, a NULL value is returned.

l Index is a metric, fact, column, or constant value that determines which


group of characters are returned. A common practice is to provide a
constant numerical value. For example, using a value of 1 returns the first
group of characters before the first delimiter characters are found in the
string.

l SeparatatorRegex is a parameter that determines if a regular


expression is used to provide the delimiter characters. The regular
expressions supported by this function conform to the standards of the
Intern a ion al Components for Unicode. For information about these
regular expression standards and syntax, see http://userguide.icu-
project.org/strings/regexp.

Example

l Split<SeparatorRegex=True>("red yellow green", "\s", 2)

This returns the string of characters "yellow". By using the regular expression \s, any
white space character is considered a delimiter. This splits the string into the strings
"red", "yellow", and "green".

l Split("red; yellow; green", ";" 1)

Copyright © 2023 All Rights Reserved 312


Fu n ct io n s Refer en ce

This returns the string of characters "red".

l Split("red; yellow; green", ";" 3)

This returns the string of characters " green".

l Split("red; yellow; green", ";" 4)

This returns a NULL value, since the string is only split into three separate strings.

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:

l Argument is a metric, fact, column, or string representing the text string


(s).

l Position is an integer indicating the starting position inside the string.

l Length is an integer indicating the number of characters to be returned.

For information on the syntax used in your specific database, see Appendix
A, 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

Copyright © 2023 All Rights Reserved 313


Fu n ct io n s Refer en ce

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.

TitleCap (Title Capitalization)


The TitleCap function returns a string in which the first letter of every word
in the input string is capitalized. All other letters that are not the first letter in
a word appear in lower case. This can help to fix capitalization errors in
information that is displayed for attribute forms, metrics, and other objects.

A word in a string is any string of alphabetic characters that are separated


by a non-alphabetic character such as a space, comma, or number.

To capitalize only the first letter of the first word in a string, see InitCap
(Initial Capitalization), page 299.

Syntax

TitleCap(Argument)

Where:

Argument is a metric, column, or string value representing the text string.

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

Example

TitleCap("john smith")

This example would return John Smith.

TitleCap("john SMITH")

This example would also return John Smith.

Copyright © 2023 All Rights Reserved 314


Fu n ct io n s Refer en ce

ToNumber (Convert String to a Number)


The ToNumber function converts a string of characters to its applicable
numeric value. Converting data that has been processed as a string to a
numeric value allows you to perform various calculations and analysis that
can be done only with numeric values.

Syntax

ToNumber(Argument)

Where:

Argument is a fact, metric, column, or constant value that provides the


strings that are converted to numeric values. The function can recognize E
notation and return the appropriate number.

Example

ToNumber("1001")

This example returns the numeric value 1001.

ToNumber("1.48e12")

This example returns the numeric value 1,480,000,000,000.

ToString (Convert Number, Date, or Timestamp to a String)


The ToString function converts a number, date, or timestamp to a string of
characters. Converting data that has been processed as a numeric, date, or
timestamp value to a string allows you to view and display the data in
different ways.

Syntax

ToString<Pattern=null>(Argument)

Where:

Copyright © 2023 All Rights Reserved 315


Fu n ct io n s Refer en ce

l Argument is a fact, metric, column, or constant value that provides the


values that are converted to a string of characters.

l Pattern is a parameter that determines the formatting for the resulting


string of characters. When providing a pattern, enclose the pattern in
double quotes (""). For example:

ToString<pattern="0,000.00">(Revenue)

To specify a pattern, you can use the custom numeric, date, and time
formatting symbols that are described in the Advanced Reporting Help.

Example

ToString<pattern="0,000.00">(1001)

This example returns the string "1,001.00".

Trim
The Trim function returns a string in which blank spaces on either side of
the input string have been removed. For example, using the Trim function
on the string " MicroStrategy" would return the string "MicroStrategy".

The Trim function helps to remove leading and trailing blank spaces, which
may have been caused by errors in data entry. Removing these spaces
helps standardize the display of information and makes the information more
readable.

Syntax

Trim(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, see Appendix
A, MicroStrategy and Database Support for Functions and see the section
that corresponds to your database.

Example

Copyright © 2023 All Rights Reserved 316


Fu n ct io n s Refer en ce

An LU_CUSTOMER table includes an ADDRESS column. You can create an


attribute form to remove any leading and trailing blank spaces from the
addresses. The definition of such an attribute form is shown below:

Trim([ADDRESS])

Any leading or trailing blank spaces included in the addresses are removed
from the display for the attribute form.

Upper (Upper Case)


The Upper function returns a string in which all alphabetic characters in an
input string are displayed as upper case. For example, using the Upper
function on the string "MicroStrategy" would return the string
"MICROSTRATEGY". The Upper function can be used to display information
in all upper case for attribute forms.

Syntax

Upper(Argument)

Where:

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

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

Example

An LU_CUSTOMER table includes an ADDRESS column. You can create an


attribute form to display all characters for a customer's address in upper
case. The definition of such an attribute form is shown below:

Upper([ADDRESS])

An attribute form using a definition such as the one listed above would take
input addresses such as 10 Main Street, 350 West Elm Avenue, and 4400

Copyright © 2023 All Rights Reserved 317


Fu n ct io n s Refer en ce

Spring Road and display them as 10 MAIN STREET, 350 WEST ELM
AVENUE, and 4400 SPRING ROAD, respectively.

Copyright © 2023 All Rights Reserved 318


Fu n ct io n s Refer en ce

O PERATORS

Copyright © 2023 All Rights Reserved 319


Fu n ct io n s Refer en ce

The operators described in this chapter are building block functions. They
provide the means to perform simple mathematical operations, compare
values, search strings, and evaluate logical conditions.

Operators may not be available for direct selection when creating


MicroStrategy objects such as metrics. These operators are employed to
support the logic of metrics, filters, thresholds, and so on.

The following categories of operators are covered in this chapter:

Arithmetic Operators
The arithmetic operators are basic mathematical functions, such as Minus,
Times, Divide, Plus, and Unary Minus, which are among the most commonly
used operators. A brief description of each operator follows.

Minus (-)
Returns the difference between two values.

Syntax

Arg1 - Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
big decimals, date/time, or functions that return numbers or big decimals.
Both Arg1 and Arg2 must be of the same data type, with the exception if
Arg1 is a Date data type. In this case, Arg2 must be a number.

Example

A metric is defined as:

Revenue - Freight

This metric returns the difference between the revenue and freight charges.

Copyright © 2023 All Rights Reserved 320


Fu n ct io n s Refer en ce

Times (*)
Returns the product of two values.

Syntax

Arg1 * Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers
or big decimals, or functions that return numbers or big decimals.

Example

A metric is defined as:

([Unit Profit] * [Units Sold])

This metric returns the product of the unit profit and the units sold values.

Divide (/)
Returns the quotient when one value is divided by another.

Syntax

Arg1 / Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers
or big decimals, or functions that return numbers or big decimals. In
addition, Arg2 must not be zero.

Example

A metric is defined as:

(Profit / [Units Sold])

This metric returns the quotient of the profit and number of units sold.

Copyright © 2023 All Rights Reserved 321


Fu n ct io n s Refer en ce

Plus (+)
Returns the sum of two values.

Syntax

Arg1 + Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers
or big decimals, or functions that return numbers and big decimals. In
addition, if either of the two arguments is date/time, the other argument must
be a number.

Example

A metric is defined as:

Cost + Freight

This metric returns the sum of the cost and the freight charges.

Unary minus (U-)


Returns the absolute value of a negative value or the negative value of a
positive value.

Syntax

U-(Arg)

Where:

Arg is an attribute, fact, metric representing a list of numbers, or a function


that returns numbers and big decimals.

Example

A metric is defined as:

U-(Profit)

Copyright © 2023 All Rights Reserved 322


Fu n ct io n s Refer en ce

This metric changes the sign of the profit value. If the profit value is
negative, it returns a positive value. If the profit value is positive, it returns a
negative value.

Comparison Operators
These operators are used to compare values, which can be numbers, text
strings, date and time, expressions, or operators that return any values of
the mentioned data types. A brief description of each operator follows. The
comparison patterns of text strings may or may not be case-sensitive
depending on the database implementation.

Less Than (<)


Returns TRUE if the first value is less than the second value.

Syntax

Arg1 < Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit < Cost

This condition returns TRUE only if the profit is less than the cost.

Less Than or Equal (<=)


Returns TRUE if the first value is less than or equal to the second value.

Syntax

Arg1 <= Arg2


Copyright © 2023 All Rights Reserved 323
Fu n ct io n s Refer en ce

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit <= Cost

This condition returns TRUE only if the profit is less than or equal to the
cost.

Not Equal (<>)


Returns TRUE if two given values are not equal to each other.

Syntax

Arg1 <> Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit <> Cost

This condition returns TRUE only if the profit is not equal to the cost.

Equal (=)
Returns TRUE if the two given values are equal to each other.

Syntax

Arg1 = Arg2

Copyright © 2023 All Rights Reserved 324


Fu n ct io n s Refer en ce

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit = Cost

This condition returns TRUE if the profit is equal to the cost.

Greater (>)
Returns TRUE if the first value is greater than the second value.

Syntax

Arg1 > Arg2

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit > Cost

This condition returns TRUE only if the profit is greater than the cost.

Greater Than or Equal (>=)


Returns TRUE if the first value is greater than or equal to the second value.

Syntax

Arg1 >= Arg2

Copyright © 2023 All Rights Reserved 325


Fu n ct io n s Refer en ce

Where:

Arg1 and Arg2 are attributes, facts, metrics representing a list of numbers,
text strings, date/time, or functions that return literal values. Arg1 and Arg2
must be of the same data type.

Example

A condition is defined as:

Profit >= Cost

This condition returns TRUE only if the profit is greater than or equal to the
cost.

Begins With
Returns TRUE if a text string begins with a specified text pattern.

For the definition and syntax of the BeginsWith string function, which can be
used to create attribute forms, see BeginsWith, page 294.

Syntax

Arg1 Begins With Arg2

Where:

Arg1 and Arg2 are text strings.

The text pattern comparison may or may not be case sensitive depending on
the database implementation.

Example

Region@DESC Begins with "North"

Returns TRUE for Regions that start with North, such as Northeast and
Northwest.

Copyright © 2023 All Rights Reserved 326


Fu n ct io n s Refer en ce

Between
Returns TRUE if the specified value is between the inclusive range of two
boundaries. Between can be used to test if a value is within a valid data
range.

Syntax

Value Between Boundary1 and Boundary2

Where:

Value, Boundary1, and Boundary2 can be numbers, date/time, text, or


functions that return the mentioned data types. Value, Boundary1 and
Boundary2 must be of the same data type.

Example

l M1 Between 1 and 1000

l region@DESC Between "A" and "Z"

l date@DESC Between '1999-2-12' and '2005-2-23'

Contains
Returns TRUE if a text string contains a specified text pattern.

Syntax

Arg1 Contains Arg2

Where:

Arg1 and Arg2 must be of data type Text.

Example

Employee@[Last Name] Contains "Smith"

Returns TRUE for Employees with a last name such as "Smith", "Smithson",
and so on.

Copyright © 2023 All Rights Reserved 327


Fu n ct io n s Refer en ce

Ends With
Returns TRUE if a text string ends with a specified text pattern.

For the definition and syntax of the EndsWith string function, which can be
used to create attribute forms, see EndsWith, page 298.

Syntax

Arg1 Ends With Arg2

Where:

Arg1 and Arg2 must be of data type Text.

Example

Employee@[Last Name] Ends with "son"

Returns TRUE for Employees with a last name that ends with son, such as
Wilson, Johnson, and so on.

In
Returns TRUE if a value is contained in a specified list of values.

Syntax

Arg1 In Arg2

Where:

Arg2 is a list of the literals with the same data type as Arg1. It can be of the
data type numbers, big decimals, text, date/time, or functions that return
these data types.

Examples

l Employee@[Last Name] in ("Smith", "Cooper", "Michael")

l Year in (2000, 2001, 2002)

Copyright © 2023 All Rights Reserved 328


Fu n ct io n s Refer en ce

Like
Returns TRUE if a text string matches a specified text pattern; otherwise,
returns FALSE.

Depending on whether you use wildcards and how they are used in the text
in the pattern, Like can be used in place of Begins With, Ends With,
Contains, or =. This operator is used to search for related strings.

Syntax

Arg1 Like Arg2

Where:

Arg1 and Arg2 must be of data type Text.

Usage Notes

Using wildcards with the Like operator allows you to search for more than
just a static set of text. For example, rather than searching for the exact text
pattern South, you can use wildcards to search for any text pattern that
includes South, such as Mid Southern, SouthEast, and South.

The Like operator can be processed by the MicroStrategy Analytical


Engine, or it can be passed to the database to be processed using the
database's own comparison support. You can determine if the Like operator
was processed by the MicroStrategy Analytical Engine or passed to the
database by viewing the SQL view of a report. If the Like operator is
included in the SQL of the report, the database performed the comparison.

By contrast, if the Like operator is not included in the SQL of the report, or
the Like operator is part of retrieving results from an Intelligent Cube (see
the In-memory Analytics Guide for reporting on Intelligent Cubes), then the
MicroStrategy Analytical Engine processed the Like operator. Wildcard
support depends on how the Like operator is processed:

Copyright © 2023 All Rights Reserved 329


Fu n ct io n s Refer en ce

l If the MicroStrategy Analytical Engine processes the Like operator, the


following wildcard characters are supported:

l The % character can be used to represent any number of characters. For


example, using the comparison Like 'Sout%' returns TRUE for South,
SouthEast, and Southern.

l The _ character can be used to represent a single character. For


example, using the comparison Like 'Sout_' returns TRUE for South
but returns FALSE for SouthEast and Southern.

l The \ character can be used as an escape character for the %, _, or \


characters, which means it can be used prior to these wildcard
characters to search for the character rather than to use it as a wildcard.
To search for the characters %, _, or \, you must include a single \
character before the character you are searching for. For example, to
search for the exact text User_ID, you would need to use the
comparison Like 'User\_ID'.

l The * character can be used to represent any number of characters. For


example, using the comparison Like 'Sout*' returns TRUE for South,
SouthEast, and Southern. The * character also acts as its own escape
character, which means it can be used prior to another * to search for
asterisks in text patterns. For example, to search for the exact text
User*, you would need to use the comparison Like 'User**'.

l If the database processes the Like operator, the database determines


how wildcards are supported. In general, many databases support the
same wildcard characters and escape characters that are listed above as
supported by the MicroStrategy Analytical Engine. However, some
databases do not support \ as an escape character and instead use an
alternative such as enclosing the wildcard character in brackets. For
example, a database may support using [%] to search for the % character.
Therefore, if the Like operator is being processed by the database, see
your third-party database documentation to verify which wildcards can be
used as part of a comparison.

Copyright © 2023 All Rights Reserved 330


Fu n ct io n s Refer en ce

Example

l Region@DESC like 'South'

Returns TRUE if region is "South".

l Region@DESC like 'South%'

Returns TRUE if region is "South," "SouthEast," and so on.

l Region@DESC like '%South%'

Returns TRUE if region is "Mid Southern," "SouthEast," "South," and so on.

l Region@DESC like 'D_g'

Returns TRUE if region is "Dog," "Dig," "Dug," and so on.

l Region@DESC like 'D*g'

Returns TRUE if region is "Dog," "Drag," "Drug," and so on.

Not Begins With


Returns TRUE if a text string does not begin with a specified text pattern.

Syntax

Arg1 Not Begins With Arg2

Where:

Arg1 and Arg2 must be of data type Text.

Example

Region@DESC Not Begins with "South"

Returns TRUE if region is "Northeast", "North", and so on.

Not Between
Returns TRUE if a specified value does not lie in between two given
boundaries.

Copyright © 2023 All Rights Reserved 331


Fu n ct io n s Refer en ce

Syntax

Value Not Between Boundary1 and Boundary2

Where:

Value, Boundary1, and Boundary2 must be of the same data type. They
can be of any data type that MicroStrategy supports.

Example

Year not between 2000 and 2005

Returns TRUE if Year = 1999

Not Contains
Returns TRUE if a text string does not contain the specified text pattern.

Syntax

Arg1 Not Contains Arg2

Where:

Arg1 and Arg2 must be of Text data type.

Example

Region@DESC Not Contains "South"

Returns TRUE if region is "North", "West", and so on.

Not Ends With


Returns TRUE if a text string does not end with the specified text pattern.

Syntax

Arg1 Not Ends With Arg2

Where:

Arg1 and Arg2 must be of Text data type.

Copyright © 2023 All Rights Reserved 332


Fu n ct io n s Refer en ce

Example

Region@DESC Not Ends With "East"

Returns TRUE if region is "Northwest", "West", and so on.

Not In
Returns TRUE if a given value is not in the specified list of values.

Syntax

Arg1 not in Arg2

Where:

Arg2 must be a list with one or more elements. Arg1 must be of the same
data type as the elements in Arg2. Arg1 and Arg2 can be of any data type
that MicroStrategy supports.

Example

Year not in (2002, 2003)

Returns TRUE if year is 2000, 2001, and so on.

Not Like
Returns TRUE if a text string does not match the specified text pattern;
otherwise, returns FALSE.

Syntax

Arg1 Not Like Arg2

Where:

Arg1 and Arg2 must be of data type Text.

Example

Region@DESC not like "South%"

Returns TRUE if region is "Northeast", "North", "Mid South", and so on.

Copyright © 2023 All Rights Reserved 333


Fu n ct io n s Refer en ce

Comparison for Rank Operators


These operators compare rank values. The Comparison for rank operators
are:

Less Than or Equal Enhanced (*<=)


Returns TRUE for values in a list which are less than or equal to a specified
condition. The list values are generated from the Rank function.

Syntax

ValueList *<= Condition

Where:

l ValueList is the list of the rank values of a metric.

l Condition is the value to be compared.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

l Operator: *<=

l Value: 2

Returns TRUE for the values of M1 whose rank values are less than or equal
to 2.

Not Equal Enhanced (*<>)


Returns TRUE for values in a list which are not equal to a specified condition.
The list values are generated from the Rank function.

Syntax

ValueList *<> Condition

Copyright © 2023 All Rights Reserved 334


Fu n ct io n s Refer en ce

Where:

l ValueList is the list of the rank values of a metric.

l Condition is the value to be compared.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

l Operator: *<>

l Value: 2

Returns TRUE for the values of M1 whose rank values are not equal to 2.

Equal Enhanced (*=)


Returns TRUE for values in a list which are equal to a specified condition.
The list values are generated from the Rank function.

Syntax

ValueList *= Condition

Where:

l ValueList is the list of the rank values of a metric.

l Condition is the value to be compared.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

Copyright © 2023 All Rights Reserved 335


Fu n ct io n s Refer en ce

l Operator: *=

l Value: 2

Returns TRUE for the values of M1 whose rank values are equal to 2.

Greater Than or Equal Enhanced (*>=)


Returns TRUE for values in a list which are greater than or equal to a
specified condition. The list values are generated from the Rank function.

Syntax

ValueList *>= Condition

Where:

• ValueList is the list of the rank values of a metric.

• Condition is the value to be compared.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

l Operator: *>=

l Value: 2

Return TRUE for the values of M1 whose rank values are greater than or
equal to 2.

Between Enhanced (*Between)


Returns TRUE for the values in a list of values that are in a specified range.
The values are generated from the Rank function.

Syntax

ValueList *Between Condition1 and Condition2

Copyright © 2023 All Rights Reserved 336


Fu n ct io n s Refer en ce

Where:

l ValueList is the list of the rank values of a metric.

l Condition1 and Condition2 set the range of values to be compared.

Usage Notes

*Between is inclusive which means any value greater than or equal to


Condition1 and less than or equal to Condition2 will return TRUE.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

l Operator: *between

l Value: 2 and

l Value: 8

Returns TRUE for the values of M1 whose rank values are between 2 and 8.

Not Between Enhanced (Not *Between)


Returns TRUE if a list of rank values is not within a specified range. The
values are generated from the Rank function.

Syntax

ValueList Not *Between Condition1 and Condition2

Where:

l ValueList is the list of the rank values of a metric.

l Condition1 and Condition2 set the range of values to be compared.

Usage Notes

Copyright © 2023 All Rights Reserved 337


Fu n ct io n s Refer en ce

Values equal to Condition1 and Condition2 are not satisfied with the
condition.

Example

Build a Set Qualification filter with

l Metric: M1

l Function: Rank

l Operator: *Not between

l Value: 2 and

l Value: 8

Return TRUE for the values of M1 whose rank values are less than 2 or
greater than 8.

Logical Operators
The logical operators allow certain conditions to be applied to two sets of
filter expressions simultaneously.

And
Returns TRUE if both the specified conditions are TRUE; otherwise, returns
FALSE.

Syntax

Arg1 And Arg2

Where:

Arg1 and Arg2 are conditional expressions. The condition can contain
metrics, comparison and logical operations, functions, and constants. The
condition must be evaluated as TRUE or FALSE.

Example

Copyright © 2023 All Rights Reserved 338


Fu n ct io n s Refer en ce

A condition is defined as:

(Cost < 1000) And (Freight < 500)

This condition will return TRUE only if both, the Cost is less than 1000, and
the Freight is less than 500.

IF
Returns a value if the specified condition is TRUE; otherwise, a default value
is returned. This is a single value function.

Syntax

IF (Condition, TrueBranch, FalseBranch)

In this guide, lists of attributes, metrics, values, parameters, etc. within a


function are separated by commas. Your separator may vary depending on
your number and date format locale. For example, the separator is a comma
(,) in English and a semicolon (;) in German.

Where:

l Condition is the conditional expression. The condition can contain


metrics, comparison and logical operations, and constants. The condition
must be evaluated to be TRUE or FALSE.

l TrueBranch is a constant or metric value to return if the condition is


TRUE.

l FalseBranch is a constant or metric value to return if the condition is


FALSE.

Usage Notes

FalseBranch must be provided; otherwise the return value is undefined.

Example

A metric is defined as:

IF ((Total Revenue < 300000), 0, 1)

Copyright © 2023 All Rights Reserved 339


Fu n ct io n s Refer en ce

This metric returns 0 if the Total Revenue is less than 300,000; otherwise, it
returns 1.

Not
Returns TRUE if the specified condition is FALSE, and FALSE if the condition
is TRUE.

Syntax

Not(Arg1)

Where:

Arg1 is the conditional expression. The condition can contain metrics,


comparison and logical operations, and constants. The condition must be
evaluated as TRUE or FALSE.

Example

A condition is defined as:

Not ((Profit <= 0))

This condition returns TRUE only if the profit is greater than zero.

Or
Returns FALSE if both the specified conditions are FALSE; else returns
TRUE.

Syntax

Arg1 Or Arg2

Where:

Arg1 and Arg2 are conditional expressions. The condition can contain
metrics, comparison and logical operations, and constants. The condition
must be evaluated as TRUE or FALSE.

Copyright © 2023 All Rights Reserved 340


Fu n ct io n s Refer en ce

Example

A condition is defined as:

(Cost <= 1000) Or (Freight <= 500)

This condition returns FALSE only if the Cost is greater than 1000, and the
Freight is greater than 500.

Copyright © 2023 All Rights Reserved 341


Fu n ct io n s Refer en ce

PLUG -I N PACKAGE
FUN CTION S

Copyright © 2023 All Rights Reserved 342


Fu n ct io n s Refer en ce

The functions in this chapter represent the more advanced functions


available in MicroStrategy, including data mining, financial, mathematical,
and statistical functions. For more information on the plug-in functions and
how to install the Function Plug-in Wizard, see Using Custom Plug-In
Functions, page 79.

Each section briefly describes the category of function and then lists each
function along with information designed to provide data necessary for
understanding and implementing an individual function. The information
provided for each function includes:

l An explanation of the data returned by the function

l The syntax of the function including function name, the available


parameters, the parameter setting defaults, and the types of data possible
for use with the function

l The mathematical expression illustrating exactly how the calculation is


defined in MicroStrategy (if applicable)

l Usage notes describing any error conditions, invalid data types, or key
items to know before using the function (if applicable)

l An example of the function in use; this can be either a report example or a


simple text description of the data returned based on the specified input

For a list of databases and the functions they support, see Appendix A,
MicroStrategy and Database Support for Functions.

The following categories of functions are covered:

Data Mining Functions


Data mining generally refers to examining a large amount of data to extract
valuable information. The data mining process uses predictive models based
on existing and historical data to project potential outcome for business

Copyright © 2023 All Rights Reserved 343


Fu n ct io n s Refer en ce

activities and transactions. MicroStrategy Data Mining Services facilitates


the development and deployment of these predictive models.

Data mining is covered in the Data Mining Services chapter of the Advanced
Reporting Help. The Data Mining Services chapter introduces MicroStrategy
Data Mining Services, which includes these features:

l Using MicroStrategy and the Training Metric Wizard to create multi-


variable regression predictive models

l Support for importing third-party predictive models using the PMML


industry standard

l A Predictive Model Viewer that visualizes the predictive model

l A set of sample predictive metrics and reports incorporated into Customer


Analysis Module (CAM)

In addition, the Data Mining Services chapter of the Advanced Reporting


Help describes the process of how to create and use predictive models with
MicroStrategy and provides a business case for illustration.

The data mining functions that are available within MicroStrategy are
employed when using standard MicroStrategy Data Mining Services
interfaces and techniques, which includes the Training Metric Wizard and
importing third-party predictive models. To ensure proper functionality, it is
recommended to use these MicroStrategy data mining functions within the
Data Mining Services interfaces and techniques, rather than manually
defining the values and parameters for these functions.

Functions for R Integration


MicroStrategy supports the integration and deployment of analytics from the
R statistical environment to MicroStrategy Web or Workstation. Customers
interested in deploying analytics from the R programming language into
MicroStrategy can do so using the R Integration Pack, available on the
MicroStrategy GitHub site.

Copyright © 2023 All Rights Reserved 344


Fu n ct io n s Refer en ce

The third-party R environment is freely available, as a separate download,


from CRAN-R.

Once you have downloaded and configured the R Integration Pack, there are
several functions available in MicroStrategy Web or Workstation that allow
you to deploy your R analytics. These functions include:

For the functions listed below, scalars are variables with a single value
while vectors are variables with one or more values.

l RScript: Supports R scripts that use vectors for the inputs and output.
Sorting is also supported.

l RScriptAgg: Supports R scripts that use vectors for the inputs and a
scalar output. Sorting is also supported.

l RScriptAggU: Supports R scripts that use vectors for the inputs and a
scalar output. This is a version of the RScriptAgg function that does not
include sorting.

l RScriptSimple: Supports R scripts that use scalar for the inputs and
output. Sorting is not supported.

l RScriptU: Supports R scripts that use vectors for the inputs and output.
This is a version of the RScript function that does not include sorting.

The easiest way to create a metric expression that utilizes these functions

A metric expression that can then be used in a derived metric to include the
statistical analysis of an R script in a MicroStrategy Web or Workstation
dossier. The R Integration Pack User Guide provides steps to use the
deployR utility to create metric expressions for R scripts.

When defining these functions in MicroStrategy Web or Workstation, you


have the following options:

l Value1, ..., ValueN: The MicroStrategy metrics that act as inputs for
the R script.

Copyright © 2023 All Rights Reserved 345


Fu n ct io n s Refer en ce

l BooleanParam1, ..., BooleanParam9: A set of boolean parameters


that allow you to pass boolean values into R scalar values that do not
change from execution to execution. If you use any boolean parameters in
your R script, you can define the default value for the parameter when
using the function in MicroStrategy Web or Workstation.

l NumericParam1, ..., NumericParam9: A set of numeric parameters


that allow you to pass numeric values into R scalar values that do not
change from execution to execution. If you use any numeric parameters in
your R script, you can define the default value for the parameter when
using the function in MicroStrategy Web or Workstation.

l StringParam1, ..., StringParam9: A set of string parameters that


allow you to pass string values into R scalar values that do not change
from execution to execution. If you use any string parameters in your R
script, you can define the default value for the parameter when using the
function in MicroStrategy Web or Workstation.

l _WorkingDir: The R scripts working directory, which is used to store


various supporting files.

l _OutputVar: The R variable that is used as the output for the metric. If
there is more than one output, the first output is considered the default
output unless otherwise specified here.

l _NullsAllowed: Controls whether records containing null values are to


be passed in as inputs to your analytic:

l True (default): Null values are included in the analysis.

l False: All records containing null values are eliminated from the
analysis.

l _CheckInputCount: Controls whether MicroStrategy ensures that the


number of inputs to the metric exactly matches exactly the number of
inputs specified in the function's signature:

Copyright © 2023 All Rights Reserved 346


Fu n ct io n s Refer en ce

l True (default): If the number of inputs is different, a warning message is


returned when using the R script in MicroStrategy.

l False: If the number of inputs is different, the script execution will


attempt to proceed.

l _RScriptFile: The directory where the R script file is stored.

l _InputNames: The MicroStrategy metric names that are used as inputs to


the R script. For the R environment to be able to use the MicroStrategy
metric names in objects and graphics that R generates, the names
associated with the inputs from MicroStrategy need to be passed to R.

l _Params: For internal use only.

l BreakBy: The logical level where the calculation of values for an


expression restarts. You can select the break by attribute from the drop-
down list.

l SortBy: Controls the sorting of records before the data is passed to R. To


specify a particular sorting criterion, you can select the sort by value from
the drop-down list. Use the button to the right of the drop-down list to
define whether the sort is ascending or descending.

Financial Functions
The financial functions plug-in package in MicroStrategy provides access to
many standard financial calculations. All finance-related calculations are
performed by the MicroStrategy Analytical Engine, regardless of the
database environment.

Accrint (Accrued Interest)


Accrued interest is interest that has accumulated over a period of time, but
has not yet been paid. This function returns the amount of accrued interest
on a security that pays periodic interest.

Syntax

Copyright © 2023 All Rights Reserved 347


Fu n ct io n s Refer en ce

Accrint <Par = 1000, Basis> (Issue, FirstInterest, Settlement,


Rate, Frequency)

Where:

Issue is the issue date.

FirstInterest is the first date on which interest is accrued.

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Rate is the annual coupon rate.

Par is a parameter that indicates the par value. The default, and only valid
value is 1000.

Frequency is the number of coupon payments per year. The valid values
are, 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Expression

Copyright © 2023 All Rights Reserved 348


Fu n ct io n s Refer en ce

Where:

Ai is the number of accrued days for the ith quasi-coupon period within an
odd period

NC is the number of quasi-coupon periods that fit an odd period (if this
period contains a fraction, that fraction is rounded up to the nearest integer)

NLi is the normal length, in days, of the ith quasi-coupon period within an
odd period

Usage Notes

If Issue, FirstInterest, Settlement, or Frequency is not an integer, it is


truncated

The engine returns an empty cell if:

l Issue, FirstInterest, or Settlement is not a valid date

l
Par ¹ 1000
l
Issue ³ Settlement
l Frequency is a value other than 1, 2, or 4

l The Issue date, the FirstInterest date and the Settlement date should be
included within single quotations in the expression for the expression to be
considered as a valid expression

Example

This example displays the expression built using Accrint for a treasury bond
with the following terms:

Copyright © 2023 All Rights Reserved 349


Fu n ct io n s Refer en ce

l March 22, 2003, issue date

l June 20, 2003, first interest date

l September 16, 2003, settlement date

l 10.0 percent coupon

l $1,000 par value

l Frequency is semiannual

l Basis is 30/360

The accrued interest is defined as:

Accrint <Par=1000, Basis=0>


(‘3/22/2003’,’9/16/2003’,’6/20/2003’,0.1,2) {~+}

Accrintm (Accrued Interest at Maturity)


Accrued interest is interest that has accumulated over a period of time, but
has not yet been paid. This function returns the accrued interest amount on
a security that pays periodic interest at maturity.

Syntax

Accrintm <Par = 1000, Basis> (Issue, Maturity, Rate)

Where:

Issue is the issue date.

Maturity is the maturity date. This is the date on which the coupon
expires.

Rate is the annual coupon rate.

Par is a constant that indicates the par value. The default, and only valid,
value is 1000.

Copyright © 2023 All Rights Reserved 350


Fu n ct io n s Refer en ce

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Expression

Where:

A is the accrued time (for interest-at-maturity items, the value used is the
number of days from issue to maturity)

D is the annual-yield basis

Usage Notes

If Issue or Maturity is not an integer, it is truncated.

The engine returns an empty cell if

l Issue or Maturity is not a valid date

l Rate £ 0

l Par ¹ 1000

Copyright © 2023 All Rights Reserved 351


Fu n ct io n s Refer en ce

l The Issue date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Example

This example displays the expression built using the Accrintm function for a
note with the following terms:

l March 22, 2001, issue date

l June 20, 2003, maturity date

l 10.0 percent coupon

l $1,000 par value

l Frequency is semiannual

l Basis is Actual/365

The accrued interest at maturity is defined as:

Accrintm <Par=1000, Basis=3> (‘3/22/2001’,’6/20/2001’,0.1){~+}

Coupdaybs (Coupon Period, Beginning to Settlement)


Returns the number of days from the beginning of a coupon period to the
settlement date.

Syntax

Coupdaybs <Basis> (Settlement, Maturity, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Copyright © 2023 All Rights Reserved 352


Fu n ct io n s Refer en ce

Frequency is the number of coupon payments per year. The valid values
are 1,2 and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Usage Notes

If an argument is not an integer, it is truncated.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Coupdays (Coupon Period, Number of Days with Settlement)


Returns the number of days in the coupon period that contains the
settlement date.

Syntax

Coupdays <Basis> (Settlement, Maturity, Frequency)

Where:

Copyright © 2023 All Rights Reserved 353


Fu n ct io n s Refer en ce

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Usage Notes

The number of days between milestones is computed depending on the


chosen day basis

Coupon functions are defined against the maturity day, depending on


frequency

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression

Copyright © 2023 All Rights Reserved 354


Fu n ct io n s Refer en ce

Coupdaysnc (Coupon Period, Settlement to Next Coupon)


Returns the number of days from the settlement date to the next coupon
date.

Syntax

Coupdaysnc <Basis = 0> (Settlement, Maturity, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Usage Notes

Copyright © 2023 All Rights Reserved 355


Fu n ct io n s Refer en ce

If an argument is not an integer, it is truncated.

The engine returns an empty cell if

l Settlement or Maturity is not a valid date.

l Frequency is a number other than 1, 2, or 4.

l Settlement ³ Maturity.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Coupncd (Next Date After Settlement)


Returns a number that represents the next coupon date after settlement.

Syntax

Coupncd <Basis> (Settlement, Maturity, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Copyright © 2023 All Rights Reserved 356


Fu n ct io n s Refer en ce

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Usage Notes

If an argument is not an integer, it is truncated.

The engine returns an empty cell if:

l Settlement or Maturity is not a valid date

l Frequency is a number other than 1, 2, or 4

l
Settlement ³ Maturity

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Coupnum (Coupon, Number Payable Between Settlement and


Maturity)
Returns the number of coupons payable between the settlement date and
maturity date, rounded up to the nearest whole coupon.

Syntax

Coupnum <Basis> (Settlement, Maturity, Frequency)

Where:

Copyright © 2023 All Rights Reserved 357


Fu n ct io n s Refer en ce

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Frequency is the number of coupon payments per year. The valid values
are, 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/360)
American institutions.

Usage Notes

The number of days between milestones is computed depending on the


chosen day basis.

Coupon functions are defined against the maturity day, depending on


frequency.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Copyright © 2023 All Rights Reserved 358


Fu n ct io n s Refer en ce

Couppcd (Coupon Date, Previous)


Returns a number that represents the coupon date before settlement date.

Syntax

Couppcd <Basis> (Settlement, Maturity, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Usage Notes

If an argument is not an integer, it is truncated.


Copyright © 2023 All Rights Reserved 359
Fu n ct io n s Refer en ce

The engine returns an empty cell if:

l Settlement or Maturity is not a valid date.

l Frequency has a value other than 1, 2, or 4.

l
Settlement ³ Maturity.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Cumipmt (Cumulative Interest Paid)


Returns the cumulative interest paid on a loan over a specified period of
time.

Syntax

Cumipmt <Type = 0> (Rate, Nper, Pv, Start, End)

Where:

Rate is the interest rate.

Nper is the total number of payment periods.

Pv is the present loan value.

Start is the first period in the calculation. Payment period counting begins
at 1.

End is the last period in the calculation.

Type is the timing of the payment.

Usage Notes

Consistency is important when specifying Rate and Nper:

l For monthly payments on a four-year loan at an annual interest rate of


12%, Rate = 12%/12; Nper = 4 × 12.

Copyright © 2023 All Rights Reserved 360


Fu n ct io n s Refer en ce

l For annual payments on a four-year loan at an annual interest rate of 12%,


Rate = 12%; Nper = 4.

If Nper, Start, End, or Type is not an integer, it is truncated.

The engine returns an empty cell if:

l Rate £ 0, Nper £ 0, or Pv £ 0

l Start < 1 or End < 1

l Start > End

l Type ¹ 0

Example

A home mortgage loan has the following terms:

l Interest rate: 9.00 percent per annum (rate = 9.00% ÷ 12 = 0.0075)

l Term: 30 years (nper = 30 × 12 = 360)

l Present value: $125,000

The total interest paid in the second year of payments (periods 13 through
24) is defined as follows:

CUMIPMT(0.0075,360,125000,13,24) equals -11135.23

The interest paid in a single payment in the first month is defined as follows:

CUMIPMT(0.0075,360,125000,1,1) equals -937.50

Cumprinc (Cumulative Principal Paid)


Returns the cumulative principal paid on a loan over a specified period of
time.

Syntax

Cumprinc <Type = 0> (Rate, Nper, Pv, Start, End)

Where:

Copyright © 2023 All Rights Reserved 361


Fu n ct io n s Refer en ce

Rate is the interest rate.

Nper is the total number of payment periods.

Pv is the present loan value.

Start is the first period in the calculation. Payment period counting begins
at 1.

End is the last period in the calculation.

Type is a parameter that indicates the timing of the payment.

Usage Notes

Consistency is important when specifying Rate and Nper:

l For monthly payments on a four-year loan at an annual interest rate of


12%, Rate = 12%/12; Nper = 4 × 12.

l For annual payments on a four-year loan at an annual interest rate of 12%,


Rate = 12%; Nper = 4.

If Nper, Start, End, or Type is not an integer, it is truncated.

The engine returns an empty cell if

l Rate £ 0, Nper £ 0, or Pv £ 0

l Start< 1 or End < 1

l Start > End

l Type ¹ 0

Example

A home mortgage loan has the following terms:

l Interest rate: 9.00 percent per annum (rate = 9.00% ÷ 12 = 0.0075)

l Term: 30 years (nper = 30 × 12 = 360)

l Present value: $125,000

Copyright © 2023 All Rights Reserved 362


Fu n ct io n s Refer en ce

The total principal paid in the second year of payments (periods 13 through
24) is defined as follows:

CUMPRINC(0.0075,360,125000,13,24) equals -934.1071

The principal paid in a single payment in the first month is defined as


follows:

CUMPRINC(0.0075,360,125000,1,1) equals -68.27827

Db (Fixed-Declining Balance (Asset Depreciation))


Returns the depreciation of an asset for a specified period, using the fixed-
declining-balance method. This is a method of accelerated depreciation
which is faster than straight line depreciation early in the life of the asset.

Syntax

Db <Month> (Cost, Salvage, Life, Period)

Where:

Cost is the initial cost of the asset.

Salvage is the value of the asset at the end of the depreciation period.

Life is the number of periods over which the asset is depreciated. This is
sometimes referred to as the useful life of an asset.

Period is the period of time over which depreciation is calculated.

Month is an integer indicating the number of months in the first year.

Expression

To calculate depreciation over any given period:

Where:

Copyright © 2023 All Rights Reserved 363


Fu n ct io n s Refer en ce

To calculate depreciation for the first period:

To calculate depreciation for the last period:

Ddb (Double-Declining Balance (Asset Depreciation))


Returns the depreciation of an asset for a specified period, using the
double-declining-balance method. Double declining balance is a method of
accelerated depreciation that is twice as fast as the straight line
depreciation method.

Syntax

Ddb <Factor> (Cost, Salvage, Life, Period)

Where:

Cost is the initial cost.

Salvage is the cost at the end of depreciation.

Life is the number of periods over which depreciation occurs.

Period is the period for which depreciation is calculated.

Factor is the rate at which the balance declines.

Expression

Usage Notes

All arguments must be positive values.

The double-declining balance method computes depreciation at an


accelerated rate: depreciation is highest during the first period and
decreases with each succeeding period.

Copyright © 2023 All Rights Reserved 364


Fu n ct io n s Refer en ce

Disc (Discount Rate for a Security)


Returns the discount rate on a security. The discount rate is used to
calculate the present value of expected or future benefits and costs.

Syntax

Disc <Basis> (Settlement, Maturity, Price, Redemption)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Price is the price per $100 of face value.

Redemption is the redemption value per $100 of face value.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Copyright © 2023 All Rights Reserved 365


Fu n ct io n s Refer en ce

Where:

B is the number of days in a year (see Basis)

DSM is the number of days between settlement and maturity

Usage Notes

If Settlement or Maturity is not an integer, it is truncated.

l The engine returns an empty cell if

l Settlement or Maturity is not a valid date.

l Price £ 0 or Redemption £ 0.

l Settlement ³ Maturity.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Dollarde (Dollar Price, Converted from Fraction to Decimal)


Converts a dollar price expressed as a fraction into a dollar price expressed
as a decimal number.

Syntax

Dollarde (FractionalDollar, Decimal)

Expression

Where:

price is the dollar value to be converted

Copyright © 2023 All Rights Reserved 366


Fu n ct io n s Refer en ce

fraction is the fraction denominator value as an integer

Dollarfr (Dollar Price, Converted from Decimal to Fraction)


Converts a dollar price expressed as a decimal into a dollar price expressed
as a fraction.

Syntax

Dollarfr (DecimalDollar, Fraction)

Where:

DecimalDollar is the dollar value to be converted

Fraction is the fraction denominator value as an integer

Duration
Returns the Macauley duration for an assumed par value of $100. Duration
is the weighted average of the present value of the cash flows and is used as
a measure of a bond price’s response to changes in yield. Bonds with higher
durations face higher risk from changes in interest rates.

Syntax

Duration <Basis> (Settlement, Maturity, CouponRate, YieldRate,


Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

CouponRate is the annual interest rate of the coupon.

YieldRate is the annual yield.

Copyright © 2023 All Rights Reserved 367


Fu n ct io n s Refer en ce

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

DSC is the number of days from settlement to next coupon date

E is the number of days in settlement’s coupon period

Copyright © 2023 All Rights Reserved 368


Fu n ct io n s Refer en ce

N is the number of coupons from settlement to maturity

Usage Notes

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Effect (Effective Annual Interest Rate)


Returns the effective annual interest rate on a given amount. This is the
actual annual rate or yield on a loan.

Syntax

Effect(NominalRate, Npery)

Where:

NominalRate is the nominal interest rate.

Npery is the number of compounding periods per year.

Expression

Usage Notes

If Npery is not an integer, it is truncated.

The engine returns an empty cell if

l Either argument is nonnumeric

l NominalRate £ 0

l Npery <= 1.

Copyright © 2023 All Rights Reserved 369


Fu n ct io n s Refer en ce

Fv (Future Value)
Returns the future value of an investment based on periodic, constant
payments and a constant interest rate. The future value is equal to the
present value plus the amount of accumulated interest that would be earned.
This can be applied to future payments, with interest calculated for each
payment.

Syntax

Fv <Type> (Rate, Nper, Pmt, Pv)

Where:

Rate is the interest rate per period.

Nper is the total number of payment periods.

Pmt is the (fixed) amount paid each period. This typically includes principal
and interest, but no other fees or taxes.

Pv is the present value (lump-sum amount) of future payments. If no value is


provided, it is assumed to be 0 (zero).

Type is a parameter that indicates when payments are due.

Usage Notes

In all cases, disbursements, such as deposits, are represented by negative


numbers; funds received, such as dividends, are represented by positive
numbers.

Use the Fvschedule function for payments made with a variable or


adjustable interest rate.

Fvschedule (Future Value Schedule)


Returns the future value of an initial principal after a series of compound-
interest rates are applied. Use this function to calculate the future value of
an investment that has a variable or adjustable rate.

Syntax

Copyright © 2023 All Rights Reserved 370


Fu n ct io n s Refer en ce

Fvschedule <Basis> (Argument, PV)

Where:

Argument is a set of applicable interest rates.

PV is the present value of the investment.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Usage Notes

If Argument is nonnumeric, the engine returns an empty cell.

Use the Fv function for payments made with a constant interest rate.

Intrate (Interest Rate)


Returns the interest rate for a fully invested security. The interest rate is the
percentage value that is multiplied by the principal to determine the amount
of interest due or paid in a given period of time.

Syntax

Intrate <Basis> (Settlement, Maturity, Investment, Redemption)

Copyright © 2023 All Rights Reserved 371


Fu n ct io n s Refer en ce

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Investment is the amount invested in the security.

Redemption is the amount actually received for the security.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

Redemption is the amount actually received for the security

Copyright © 2023 All Rights Reserved 372


Fu n ct io n s Refer en ce

Investment is the amount invested in the security

B is the number of days in a year, depending on year basis

DIM is the number of days from settlement to maturity

Usage Notes

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Ipmt (Interest Payment)


Returns the interest payment for a given period, based on periodic, constant
payments and a constant interest rate.

Syntax

Ipmt < FV, Type> (Rate, Period, Nperiod, PV)

Where:

Rate is the interest rate per period.

Period is the period for which the interest payment is sought. The valid
range is from 1 to Nperiod.

Nperiod is the total number of payment periods.

PV is the present value. This is the total value that a series of future
payments has today.

FV is a parameter that indicates the future value, also called the cash
balance, expected after the last payment is made.

Type is a parameter that indicates when payments are due.

Usage Notes

For this function, consistency in the units used is necessary:

Copyright © 2023 All Rights Reserved 373


Fu n ct io n s Refer en ce

l Assuming monthly payments on a four-year loan at 12% annual interest,


Nperiod should be 4 × 12.

l Assuming annual payments on a four-year loan at 12% annual interest,


Nperiod should be 4.

For this function, disbursements (such as deposits to savings) are


represented by negative numbers; funds received (such as dividend checks)
are represented by positive numbers.

IRR (Internal Rate of Return)


Returns the internal rate of return on a set of payments. The internal rate of
return is the interest rate received for an investment consisting of payments
that occur periodically. These payments do not need to be equal in value,
but they must occur at regular intervals, such as monthly, quarterly, or
annually.

To calculate the internal rate of return for payments that do not occur at
regular intervals, see XIRR (Internal Rate of Return for Payments at
Irregular Intervals), page 405.

Syntax

IRR <FactID, Guess, METHOD, Precision, SortBy> (Argument)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Guess is a parameter that indicates an estimate assumed to be close to the


result sought. The default value is 0.1, which can be thought of as
representing an expected internal rate of return of 10 percent.

Method is a parameter that determines the algorithm used to calculate the


IRR function. You can use the following values:

Copyright © 2023 All Rights Reserved 374


Fu n ct io n s Refer en ce

l 0 (default): The IRR function uses the secant method to determine the
internal rate of return. This is the recommended method as it can adjust
the initial guess as required to return a result.

l 1: The IRR function uses Newton’s method to determine the internal rate
of return. This method can return results similar to those returned for
internal rate of return functions that are supplied with Microsoft Excel.

Precision is a parameter that determines how close the evaluation of a


potential solution must be to zero to be considered valid.

Argument is a fact or metric representing a list of numbers for which the


internal rate of return is sought.

SortBy is a parameter that defines the order of calculation. For more


information see BreakBy and SortBy Parameters, page 27.

Usage Notes

The list of values must contain at least one positive entry and one negative
entry.

Payments, whether positive or negative, must be entered in the desired


sequence, as this is the order in which entries are interpreted for
calculation.

Mduration (Modified Duration)


Returns the modified Macauley duration, which is the weighted average of
present payments, for a security with an assumed par value of $100. This
function is used as a measure of bond-price response to variations in yield.

Syntax

Mduration <Basis> (Settlement, Maturity, CouponRate, YieldRate,


Frequency)

Where:

Copyright © 2023 All Rights Reserved 375


Fu n ct io n s Refer en ce

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the date of maturity. This is the date on which the security
expires.

CouponRate is the annual interest rate of the coupon.

YieldRate is the annual yield.

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis used. The default
value for Basis is 0, which is typically used by American agencies and
assumes 30-day months and 360-day years (30/360). Possible values for
this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

Copyright © 2023 All Rights Reserved 376


Fu n ct io n s Refer en ce

yld is the security annual yield

frequency is the number of coupon payments per year

Usage Notes

If Settlement, Maturity, or Frequency is not an integer, it is truncated.

The engine returns an empty cell if:

l Either Settlement or Maturity is not a valid date

l CouponRate < 0

l YieldRate < 0

l Frequency is a number other than 1, 2, or 4

l Settlement ³ Maturity

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

MIRR (Modified Internal Rate of Return)


Returns the modified internal rate of return on a set of periodic payments.
This function takes into consideration both the cost of investment and the
interest received on investment.

To calculate the internal rate of return for payments that do not occur at
regular intervals, see XIRR (Internal Rate of Return for Payments at
Irregular Intervals), page 405.

Syntax

MIRR <FactID> (Argument, FinancialRate, ReinvestRate)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Copyright © 2023 All Rights Reserved 377


Fu n ct io n s Refer en ce

Argument is a list of values containing a set of numbers. Entries in this list


can represent payments (negative values) or income (positive values)
occurring at regular intervals.

FinancialRate is the interest rate paid.

ReinvestRate is the interest rate received on reinvested funds.

Expression

Usage Notes

If Argument does not contain at least one positive entry (income) and one
negative entry (payments), the engine returns an empty cell.

In calculating the return for this function, the order in which entries are
provided is assumed to be the order in which funds flow; it is important,
therefore, that payments and income be entered in the correct sequence.

Nominal (Nominal Annual Interest Rate)


Returns the nominal annual interest rate on an investment, based on the
effective rate and the number of compounding periods per year. This is the
interest rate that is not adjusted for actual or expected inflation.

Syntax

Nominal(EffectiveRate, Npery)

Where:

EffectiveRate is the effective interest rate.

Npery is the number of compounding periods per year.

Expression

Copyright © 2023 All Rights Reserved 378


Fu n ct io n s Refer en ce

Usage Notes

If Npery is not an integer, it is truncated.

The engine returns an empty cell if

l Either argument is nonnumeric

l EffectiveRate £ 0

l Npery < 1

Nper (Number of Investment Periods)


Returns the number of periods for an investment, based on periodic,
constant payments and a constant interest rate.

Syntax

Nper <Type> (Rate, Pmt, PV, FV)

Where:

Rate is the internal rate for each period.

Pmt is the amount paid each period. Typically it includes principal and
interest, but no other fees or taxes.

PV is the present value of a series of future payments. If this value is


omitted, is assumed to be 0 (zero).

FV is the value that remains after the last payment is made.

Type is a number that indicates when payments are due.

NPV (Net Present Value of an Investment)


Returns the net present value of an investment based on a discount rate and
a set of future payments (negative values) and income (positive values).

Copyright © 2023 All Rights Reserved 379


Fu n ct io n s Refer en ce

All payments and incomes must be equally spaced in time, and occur at the
end of each period. To calculate the net present value of an investment in
which payments and income do not occur at regular intervals, see XNPV
(Net Present Value of an Investment for Payments or Incomes at Irregular
Intervals), page 408.

Syntax

NPV <FactID, SortBy> (Argument, Rate)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

SortBy is a parameter that defines the order of calculation. For more


information see BreakBy and SortBy Parameters, page 27.

Argument is a fact or metric representing a list of values containing either


payment or income figures.

Rate is the discount rate for the length of a period.

Expression

Where:

n is the number of entries in Values.

Usage Notes

All entries in Values must be equally spaced in time, and occur at the end of
each period.

Copyright © 2023 All Rights Reserved 380


Fu n ct io n s Refer en ce

The order of the entries in Values is assumed to be the order in which funds
flow; payment and income entries must, therefore, be provided in the correct
sequence.

Investment begins one period before the date on which the first entry in
Values occurs, and ends with the last entry in that array.

If the first entry in Values occurs at the beginning of a period, it must be


added to the result of the function.

The primary differences between this function and the Present Value (PV)
function are that

l PV allows fund flow to occur either at the beginning or at the end of a


period.

l PV fund-flow occurrences must be constant across the life of the


investment.

Oddfprice (Odd-First-Period Price)


Returns the price per $100 face value of a security having an odd (short or
long) first period.

Syntax

Oddfprice <Basis> (Settlement, Maturity, Issue, FirstCoupon,


CouponRate, YieldRate, Redemption, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the date of maturity. This is the date on which the security
expires.

Issue is the issue date.

FirstCoupon is the first-coupon date.

CouponRate is the annual interest rate of the coupon.

Copyright © 2023 All Rights Reserved 381


Fu n ct io n s Refer en ce

YieldRate is the annual yield.

Redemption is the redemption value per $100 of face value.

Frequency is the number of coupon payments per year. The valid values
are 1, 2, and 4 where annual payments =1, semiannual payments =2, and
quarterly payments =4.

Basis is a parameter that indicates the time-count basis used. The default
value for Basis is 0, which is typically used by American agencies and
assumes 30-day months and 360-day years (30/360). Possible values for
this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

There are two expressions for this function:

l Odd Short First Coupon: for securities with a short first period

l Odd Long First Coupon: for securities with a long first period

Odd Short First Coupon

Copyright © 2023 All Rights Reserved 382


Fu n ct io n s Refer en ce

Where:

A is the number of days from beginning of coupon period to settlement date


(accrued days)

DSC is the number of days from settlement to next coupon date

DFC is the number of days from the beginning of odd first coupon to first
coupon date

E is the number of days in coupon period

N is the number of coupons payable between settlement date and


redemption date; if this number contains a fraction, it is raised to the next
whole number

Odd Long First Coupon

Where:

Ai is the number of days from beginning of the ith quasi-coupon period


within odd period

DCi is the Number of days from date to first quasi-coupon (i=1) or number
of days in quasi-coupons (i=2,..., i=NC)

DSC is the Number of days from settlement to next coupon date

E is the Number of days in coupon period

N is the Number of coupons payable between the first real coupon date and
redemption date; if this number contains a fraction, it is raised to the next
whole number

NC is the Number of quasi-coupon periods that fit in odd period; if this


number contains a fraction it is raised to the next whole number

Copyright © 2023 All Rights Reserved 383


Fu n ct io n s Refer en ce

NLi is the Normal length in days of the full ith quasi-coupon period within
odd period

Nq is the Number of whole quasi-coupon periods between settlement date


and first coupon

Usage Notes

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Oddfyield (Odd-First-Period Yield)


Returns the yield of a security that has an odd (short or long) first period.

Syntax

Oddfyield <Basis> (Settlement, Maturity, Issue, FirstCoupon,


CouponRate, Price, Redemption, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Issue is the issue date.

FirstCoupon is the first coupon date.

CouponRate is the annual interest rate of the coupon.

Price is the price.

Redemption is the redemption value per $100 of face value.

Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4.

Copyright © 2023 All Rights Reserved 384


Fu n ct io n s Refer en ce

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Usage Notes

If Settlement, Maturity, Issue, or FirstCoupon is not an integer, it is


truncated.

The engine returns an empty cell if:

l Settlement, Maturity, Issue, or FirstCoupon is not a valid date

l CouponRate < 0

l Price £ 0

l The following date-related condition is not satisfied: Maturity >


FirstCoupon > Settlement > Issue

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Copyright © 2023 All Rights Reserved 385


Fu n ct io n s Refer en ce

Oddlprice (Odd-Last-Period Price)


Returns the price per $100 face value of a security having an odd (short or
long) last period.

Syntax

Oddlprice <Basis> (Settlement, Maturity, LastInterest,


CouponRate, YieldRate, Redemption, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

LastInterest is the last date on which interest is accrued.

CouponRate is the annual interest rate of the coupon.

YieldRate is the annual yield.

Redemption is the redemption value per $100 of face value.

Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

1 (actual/actual) Assumes actual number of days in each month, actual number of days in

Copyright © 2023 All Rights Reserved 386


Fu n ct io n s Refer en ce

Basis value Application

each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

Ai is the Number of accrued days for the ith quasi-coupon period within odd
period counting forward from last interest date before redemption

DCi is the Number of days counted in each ith quasi-coupon period as


delimited by the length of the actual coupon period

NC is the Number of quasi-coupon periods that fit in odd period; if this


number contains a fraction, it is raised to the next whole number

NLi is the Normal length in days of the ith quasi-coupon period within odd
coupon period

DSCi is the Number of days from settlement (or beginning of quasi-coupon


period) to next quasi coupon within odd period (or to maturity date) for each
ith quasi-coupon period.

Usage Notes

Copyright © 2023 All Rights Reserved 387


Fu n ct io n s Refer en ce

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Oddlyield (Odd-Last-Period Yield)


Returns the yield of a security that has an odd (short or long) last period.

Syntax

Oddlyield <Basis> (Settlement, Maturity, LastInterest,


CouponRate, Price, Redemption, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

LastInterest is the security’s last coupon date.

CouponRate is the interest rate.

Price is the price.

Redemption is the redemption value per $100 of face value.

Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Copyright © 2023 All Rights Reserved 388


Fu n ct io n s Refer en ce

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

Ai is the number of accrued days for the ith, or last, quasi-coupon period
within odd period counting forward from last interest date before redemption.

DCi is the number of days counted in the ith, or last, quasi-coupon period as
delimited by the length of the actual coupon period.

NC is the number of quasi-coupon periods that fit in odd period; if this


number contains a fraction, it is raised to the next whole number.

NLi is the normal length in days of the ith, or last, quasi-coupon period
within odd coupon period.

Usage Notes

The date arguments should be included within single quotations for the
expression to be considered as a valid expression.

Copyright © 2023 All Rights Reserved 389


Fu n ct io n s Refer en ce

Pmt (Payment)
Returns the payment cost on a loan, based on constant payments and a
constant interest rate.

Syntax

Pmt <FV, Type> (Rate, Nper, PV)

Where:

FV a parameter that indicates the future value of the loan. It is the balance to
be attained once all payments are made.

Type is parameter that indicates when payment is due.

Rate is the interest rate.

Nper is the number of payments.

PV is the present value of the loan, also referred to as principal. This is the
current value of a set of future payments.

Usage Notes

Values returned by this function include principal and interest; they do not
include taxes, reserve payments, or ancillary fees.

Units must be used consistently when calculating payment. For example:

l To calculate monthly payments on a four-year loan at 12% annual interest,


Rate should be 12%/12, Nper should be 4 × 12.

l To calculate annual payments on the same loan, Rate should be 12%,


Nper should be 4.

This function can also be used to determine payments on annuities other


than loans.

Ppmt (Principal Payment)


Returns the payment on the principal for an investment for one given period.

Copyright © 2023 All Rights Reserved 390


Fu n ct io n s Refer en ce

Syntax

Ppmt <Type = 0, FV = 0> (Rate, Per, Nper, PV)

Where:

Type is a parameter that indicates when payment is due.

Rate is the interest rate.

Per is the period desired.

Nper is the number of payments.

PV is the present value of the loan.

FV is the future value of the loan.

Expression

Where:

i is the period desired

Price (Price Per $100 Face Value)


Returns the price, per $100 face value, on a security that pays periodic
interest.

Syntax

Price <Basis> (Settlement, Maturity, CouponRate, YieldRate,


Redemption, Frequency)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Copyright © 2023 All Rights Reserved 391


Fu n ct io n s Refer en ce

CouponRate is the annual interest rate.

YieldRate is the annual yield.

Redemption is the redemption value per $100 of face value.

Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

DSC is the number of days from settlement to next coupon date

Copyright © 2023 All Rights Reserved 392


Fu n ct io n s Refer en ce

E is the number of days in the coupon period in which the settlement date
falls

N is the number of coupons payable between the settlement date and the
redemption date

A is the number of days from the beginning of the coupon period to


settlement date

Usage Notes

If Settlement, Maturity, or Frequency is not an integer, it is truncated.

The engine returns an empty cell if:

l Settlement or Maturity is not a valid date

l CouponRate < 0 or YieldRate < 0

l Redemption £ 0

l Frequency has a value other than 1, 2, or 4

l Settlement ³ Maturity

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Pricedisc (Price, Discounted)


Returns the price, per $100 face value, on a discounted security.

Syntax

Pricedisc <Basis> (Settlement, Maturity, DiscRate, Redemption)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Copyright © 2023 All Rights Reserved 393


Fu n ct io n s Refer en ce

Maturity is the maturity date. This is the date on which the security
expires.

DiscRate is the discount rate.

Redemption is the redemption value per $100 of face value.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

B is the number of days in a year (see Basis)

DSM is the number of days from settlement to maturity

Usage Notes

If Settlement or Maturity is not an integer, it is truncated.

The engine returns an empty cell if:

Copyright © 2023 All Rights Reserved 394


Fu n ct io n s Refer en ce

l Settlement or Maturity is not a valid date

l
DiscRate £ 0 or Redemption £ 0
l
Settlement ³ Maturity

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Pricemat (Price at Maturity)


Returns the price, per $100 of face value, on a security that pays interest at
maturity.

Syntax

Pricemat <Basis> (Settlement, Maturity, Issue, CouponRate,


YieldRate)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Issue is the issue date. It is expressed as a serial date.

CouponRate is the interest rate on the date of issue.

YieldRate is the annual yield.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Copyright © 2023 All Rights Reserved 395


Fu n ct io n s Refer en ce

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

B is the number of days in a year (see Basis)

DSM is the number of days from settlement to maturity

DIM is the number of days from issue to maturity

A is the number of days from issue to settlement

Usage Notes

If Settlement, Maturity, or Issue is not an integer, it is truncated.

The engine returns an empty cell if

l Settlement, Maturity, or Issue is not a valid date

l Rate < 0 or Yield < 0

l Settlement ³ Maturity

Copyright © 2023 All Rights Reserved 396


Fu n ct io n s Refer en ce

The Settlement date, the Maturity date, and the Issue date should be
included within single quotations in the expression for the expression to be
considered as a valid expression.

Pv (Present Value)
Returns the present value of an investment.

Syntax

Pv <Type> (Rate, Nper, Pmt, FV)

Where:

Type is a value that indicates when payment is due.

Rate is the interest rate.

Nper is the number of payments.

Pmt is the periodic payment for an annuity.

FV is the future value of the loan.

Expression

If rate = 0

Else

Rate (Interest Rate Per Period)


Returns the interest rate per period on a given annuity.

Syntax

Rate <FV, Type, Guess> (Nperiod, Payment, PV)

Where:
Copyright © 2023 All Rights Reserved 397
Fu n ct io n s Refer en ce

l FVis the future value (also called cash balance) expected after the last
payment.

l Typeindicates when payments are due.

l Guess is an estimate assumed to be close to the result sought.

l Nperiod is the total number of payment periods.

l Payment is the payment made for each period. Cannot change over the
life of the annuity. Typically, includes principal and interest, but no other
fees or taxes.

l PV is the present value of the annuity. It is the total amount that a series of
future payments is worth today.

Usage Notes

l For this function, consistency in the units used is necessary:

l Assuming monthly payments on a four-year loan at 12% annual interest,


Nperiod should be 4 × 12.

l Assuming annual payments on a four-year loan at 12% annual interest,


Nperiod should be 4.

Received (Amount Received at Maturity)


Returns the amount received at maturity on a fully invested security.

Syntax

Received <Basis> (Settlement, Maturity, Investment, Discount)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the date of maturity. This is the date on which the security
expires.

Investment is the amount invested.

Copyright © 2023 All Rights Reserved 398


Fu n ct io n s Refer en ce

Discount is the discount rate.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis value Application

0 (30/360) Assumes 30 days in each month, 360 days in each year.

Assumes actual number of days in each month, actual number of days in


1 (actual/actual)
each year.

2 (actual/360) Assumes actual number of days in each month, 360 days in each year.

3 (actual/365) Assumes actual number of days in each month, 365 days in each year.

Used by European agencies, assumes the same values as “0” for


4 (30/60)
American institutions.

Expression

Where:

B is the number of days in a year (see Basis)

DIM is the number of days between settlement and maturity

Usage Notes

If Settlement or Maturity is not an integer, it is truncated.

The engine returns an empty cell if

Copyright © 2023 All Rights Reserved 399


Fu n ct io n s Refer en ce

l Settlement or Maturity is not a valid date.

l
Investment £ 0.
l
Discount £ 0.
l
Maturity £ Settlement.

l The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Sln (Straight-Line Depreciation)


Returns the straight-line depreciation of an asset over a given period. This is
the simplest method of depreciation and represents an equal amount
charged for each period during the useful life of the asset after allowing for a
salvage value.

Syntax

Sln(Cost, Salvage, Life)

Where:

Cost is the initial cost of the asset.

Salvage, also called the salvaged value of an asset, is the residual value at
the end of the estimated life span.

Life, also called the useful life of an asset, is the number of periods over
which the asset is being depreciated.

Syd (Sum of Year's Digits Depreciation)


Returns the sum of year’s digits depreciation of an asset over a specified
period. This method of accelerated depreciation results in higher
depreciation early in the life of an asset. It calculates the depreciation for
each year on an inverted scale in proportion to the total of all the digits for
the asset’s useful life.

Syntax

Copyright © 2023 All Rights Reserved 400


Fu n ct io n s Refer en ce

Syd < > (Cost, Salvage, Life, Period)

Where:

Cost is the initial cost.

Salvage, also called the salvaged value of an asset, is the residual value at
the end of the estimated life span.

Life, also called the useful life of an asset, is the number of periods over
which the asset is being depreciated.

Period is the depreciation period. This must have the same number of units
as Life.

Expression

Tbilleq (T-Bill Equity)


Returns the bond-equivalent yield of a Treasury bill.

Syntax

Tbilleq(Settlement, Maturity, Discount)

Where:

Settlement is the settlement date. This is the date on which the security is
traded.

Maturity is the maturity date. This is the date on which the treasury bill
expires.

Discount is the discount rate.

Expression

Copyright © 2023 All Rights Reserved 401


Fu n ct io n s Refer en ce

Where:

DSM is the number of days between settlement and maturity on 360-day


basis.

Usage Notes

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Tbillprice (T-Bill Price)


Returns the price of a treasury bill per $100 of face value.

Syntax

Tbillprice(Settlement, Maturity, Discount)

Where:

Settlement is the settlement date. This is the date on which the treasury
bill is purchased.

Maturity is the maturity date. This is the date on which the treasury bill
expires.

Discount is the discount rate.

Expression

Where:

DSM is the number of days from settlement to maturity.

This excludes any maturity date that is more than one calendar year past
Settlement.

Usage Notes

Copyright © 2023 All Rights Reserved 402


Fu n ct io n s Refer en ce

If Settlement or Maturity is not an integer, it is truncated.

The engine returns an empty cell if:

l Either Settlement or Maturity is not a valid date

l Discount £ 0

l Settlement > Maturity

l Maturity is more than one year after Settlement

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Tbillyield (T-Bill Yield)


Returns the yield of a treasury bill.

Syntax

Tbillyield < > (Settlement, Maturity, Price)

Where:

Settlement is the settlement date. This is the date on which the treasury
bill is purchased.

Maturity is the maturity date. This is the date on which the treasury bill
expires.

Price is the price per $100 of face value

Expression

Where:

DSM is the number of days from settlement to maturity.

Copyright © 2023 All Rights Reserved 403


Fu n ct io n s Refer en ce

This excludes any maturity date that is more than one calendar year past
Settlement.

Usage Notes

If Settlement or Maturity is not an integer, it is truncated.

The engine returns an empty cell if:

l Either Settlement or Maturity is not a valid date

l
Price £ 0
l Settlement > Maturity

l Maturity is more than one year after Settlement

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Vdb (Variable Declining Balance)


Returns the depreciation of an asset over a specified period, including
partial periods.

Syntax

Vdb <Factor> (Cost, Salvage, Life, Period)

Where:

Factor is the rate at which balance declines.

Cost is the initial cost of the asset.

Salvage is the value at the end of the depreciation period.

Life is the number of periods over which depreciation is calculated.

Period is the first period for which depreciation is calculated. This must use
the same number of units as Life.

Usage Notes

Copyright © 2023 All Rights Reserved 404


Fu n ct io n s Refer en ce

All values must be positive.

XIRR (Internal Rate of Return for Payments at Irregular


Intervals)
Returns the internal rate of return on a set of payments that do not occur at
regular intervals. The internal rate of return is the interest rate received for
an investment consisting of payments. These payments do not need to be
equal in value, and do not need to occur at regular intervals.

To calculate the internal rate of return for payments that occur at regular
intervals, see:

l IRR (internal rate of return): Internal rate of return for periodic payments.

l MIRR (modified internal rate of return): Modified internal rate of return for
periodic payments, which takes into consideration both the cost of
investment and the interest received on investment.

Syntax

XIRR <FactID, Guess, SortBy> (Payment, Dates)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Guess is a parameter that indicates an estimate assumed to be close to the


result sought. The default value is 0.1, which can be thought of as
representing an expected internal rate of return of 10 percent.

Payment is a fact or metric representing a list of numbers for which the


internal rate of return is sought.

Dates is a fact or metric representing a list of dates for the payments that
are included. Ensure that these values use a date/time format.

Usage Notes

Copyright © 2023 All Rights Reserved 405


Fu n ct io n s Refer en ce

The list of values must contain at least one positive entry and one negative
entry.

The XIRR function uses the secant method to determine the internal rate of
return, which adjusts the initial guess as required to return a result. The final
result must be within 0.000001 percent to be considered valid.

Payments, whether positive or negative, must be entered in the desired


sequence, as this is the order in which entries are interpreted for
calculation.

Example
You have an investment where payments are made at irregular intervals.
This payment and payment date information is included in MicroStrategy and
displayed on the simple report shown below:

Since the dates are not at regular intervals such as monthly or quarterly, you
cannot use the IRR function to determine the internal rate of return. Instead,
you can use the XIRR function, which also evaluates the date of each
payment to determine an internal rate of return. A new metric is added to the
report which uses the following definition:

XIRR(Payment, Date){}

The new report now includes this information, as shown below:

Copyright © 2023 All Rights Reserved 406


Fu n ct io n s Refer en ce

The internal rate of return considering the payments and the dates of those
payments is 21.93. Notice that while there is a single value for XIRR, it is
displayed on every row. One way to simplify the display of this information is
to include this data on a dashboard. You can include the XIRR result in a
text field along with additional visualizations of the data, as shown below.

Copyright © 2023 All Rights Reserved 407


Fu n ct io n s Refer en ce

XNPV (Net Present Value of an Investment for Payments or


Incomes at Irregular Intervals)
Returns the net present value of an investment based on a discount rate and
a set of future payments (negative values) and income (positive values).

These payments or incomes do not need to occur at regular intervals. To


calculate the net present value of an investment for payments and incomes
that occur at regular intervals, see NPV (net present value of an
investment).

Syntax

XNPV <FactID> (Payments, Dates, Rate)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Payments is a fact or metric representing a list of values containing either


payment or income figures.

Dates is a fact or metric representing a list of dates for the payments or


incomes that are included. Ensure that these values use a date/time format.

Rate is the discount rate applied to the cash flows. This is commonly
included in the expression as a constant value.

Expression

Where:

n is the number of entries in payments.

Copyright © 2023 All Rights Reserved 408


Fu n ct io n s Refer en ce

d i is the i th payment date and d 1 is the first payment date.

Usage Notes

The order of the entries in Payments is assumed to be the order in which


funds flow; payment and income entries must, therefore, be provided in the
correct sequence.

Example
You have an investment where payments are made at irregular intervals.
This payment and payment date information is included in MicroStrategy and
displayed on the simple report shown below:

Since the dates are not at regular intervals such as monthly or quarterly, you
cannot use the NPV function to determine the net present value. Instead, you
can use the XNPV function, which also evaluates the date of each payment to
determine a net present value. A new metric is added to the report, which
uses the following definition that includes a rate of 20%:

XNPV(Payment, Date, 0.2){}

The new report now includes this information, as shown below:

Copyright © 2023 All Rights Reserved 409


Fu n ct io n s Refer en ce

The net present value considering the payments, the dates of those
payments, and a rate of 20% is $20,379. Notice that while there is a single
value for XNPV, it is displayed on every row. One way to simplify the display
of this information is to include this data on a dashboard. You can include
the XNPV result in a text field along with additional visualizations of the data,
as shown below.

Yield
Returns the yield on a security that pays periodic interest.

Copyright © 2023 All Rights Reserved 410


Fu n ct io n s Refer en ce

Syntax

Yield <Basis> (Settlement, Maturity, CouponRate, Price,


Redemption, Frequency)

Where:

l Settlement is the settlement date. This is the date on which the security
is purchased.

l Maturity is the maturity date. This is the date on which the security
expires.

l CouponRate is the annual interest rate.

l Price is the price per $100 of face value.

l Redemption is the redemption value per $100 of face value.

l Frequency is the number of payments per year. The valid values are 1, 2,
and 4 where annual payments =1, semiannual payments =2, and quarterly
payments =4.

l Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Other possible
values for this parameter are as follows.

Basis value Application


0 (30/ 360) Assu m es 30 d ays i n each m o n t h , 360 d ays i n each year .
1 Assu m es act u al n u m b er o f d ays i n each m o n t h , act u al n u m b er o f d ays
(act u al / act u al ) i n each year .
2 (act u al / 360) Assu m es act u al n u m b er o f d ays i n each m o n t h , 360 d ays i n each year .
3 (act u al / 365) Assu m es act u al n u m b er o f d ays i n each m o n t h , 365 d ays i n each year .
Used b y Eu r o p ean agen ci es, assu m es t h e sam e val u es as “0” f o r
4 (30/ 60)
Am er i can i n st i t u t i o n s.

Expression

Copyright © 2023 All Rights Reserved 411


Fu n ct io n s Refer en ce

• If there is one period (or less) until Redemption, this function is


calculated as follows.

Where:

▫ A is the number of days from the beginning of the period to Settlement

▫ DSR is the number of days from Settlement to Redemption

▫ E is the number of days in a period

• If there is more than one period until Redemption, this function is


calculated through iteration, and is based on the calculation for the
PRICE function. See also Price (price per $100 face value).

Usage notes

• If Settlement, Maturity, or Frequency is not an integer, it is truncated.

• The engine returns an empty cell if:

▫ Either Settlement or Maturity is not a valid date.

▫ Price £ 0 or Redemption £ 0.

▫ Frequency is a number other than 1, 2, or 4.

▫ Settlement > Maturity.

• The Settlement date and the Maturity date should be included within
single quotations in the expression for the expression to be considered
as a valid expression.

Yielddisc (Yield on a Discounted Security)


Returns the annual yield on a discounted security.

Syntax

Copyright © 2023 All Rights Reserved 412


Fu n ct io n s Refer en ce

Yielddisc <Basis> (Settlement, Maturity, Price, Redemption)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the maturity date. This is the date on which the security
expires.

Price is the price per $100 of face value.

Redemption is the redemption value per $100 of face value.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis Value Application

Assumes 30 days in each month; 360 days in


0 (30/360)
each year.

Assumes actual number of days in each month,


1 (actual/actual)
actual number of days in each year.

Assumes actual number of days in each month,


2 (actual/360)
360 days in each year.

Assumes actual number of days in each month,


3 (actual/365)
365 days in each year.

Used by European agencies, assumes the same


4 (30/60)
values as 0 for American institutions.

Usage Notes

If Settlement or Maturity is not an integer, it is truncated.

The engine returns an empty cell if:

Copyright © 2023 All Rights Reserved 413


Fu n ct io n s Refer en ce

l Either Settlement or Maturity is not a valid date.

l
Price £ 0 or Redemption £ 0.
l
Maturity £ Settlement.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Yieldmat (Yield at Maturity)


Returns the annual yield on a security that pays interest at maturity.

Syntax

Yieldmat < Basis> (Settlement, Maturity, Issue, Rate, Price)

Where:

Settlement is the settlement date. This is the date, after issue, on which
the security is traded.

Maturity is the date of maturity. This is the date on which the security
expires.

Issue is the issue date.

Rate is the annual coupon rate.

Price is the price per $100 of face value.

Basis is a parameter that indicates the time-count basis to be used. The


default value for Basis is 0, which is typically used by American agencies
and assumes 30-day months and 360-day years (30/360). Possible values
for this parameter are listed in the following table.

Basis Value Application

0 (30/360) Assumes 30 days in each month; 360 days in

Copyright © 2023 All Rights Reserved 414


Fu n ct io n s Refer en ce

Basis Value Application

each year.

Assumes actual number of days in each month,


1 (actual/actual)
actual number of days in each year.

Assumes actual number of days in each month,


2 (actual/360)
360 days in each year.

Assumes actual number of days in each month,


3 (actual/365)
365 days in each year.

Used by European agencies, assumes the same


4 (30/60)
values as 0 for American institutions.

Usage Notes

If Settlement, Maturity, or Issue is not an integer, it is truncated.

The engine returns an empty cell if:

l Rate < 0.

l Price £ 0.

l Settlement ³ Maturity.

The Settlement date and the Maturity date should be included within single
quotations in the expression for the expression to be considered as a valid
expression.

Mathematical Functions
The category of Mathematical functions contains more complex math
functions than the simple operators found in the Basic Functions. This
category includes exponential, logarithmic, and trigonometric functions.
These functions are calculated by either the MicroStrategy Analytical Engine

Copyright © 2023 All Rights Reserved 415


Fu n ct io n s Refer en ce

or the database. Those not supported by the database are automatically


computed by the Analytical Engine.

Abs (Absolute Value)


Returns the absolute value of a given number. The absolute value of a
number is the number without a sign. This is a single-value function.

Syntax

Abs(Argument)

Where:

Argument is a metric representing a list of real numbers.

Example

This simple example show the results of executing the Abs function on a list
of values. Assuming you have a metric that represents deposit and
withdrawal amounts, the function operates as follows:

Abs(Deposit_Withdrawal) where Deposit_Withdrawal is the


following list of values: +756.25, -315, +145, -980.35, -75, +1250.78, +560.
The resulting value list is 756.25, 315, 145, 980.35, 75, 1250.78, 560. For
another example of using the Abs function, see Example 1: Transformed
Fact, page 12.

Acos (Arc Cosine)


Returns the arc cosine of a given number as an angle. This angle is
calculated in radians and falls between 0 and p . To convert radians to
degrees, multiply by 180/ p . This is a single-value function.

Syntax

Acos(Argument)

Where:

Copyright © 2023 All Rights Reserved 416


Fu n ct io n s Refer en ce

Argument is a metric representing a list of real numbers. The values are the
values of the cosine for the angles sought. This value must be between -1
and 1.

Acosh (Arc Cosine, Hyperbolic)


Acosh returns the inverse hyperbolic cosine of a number. This function is
the inverse of Cosh. Acosh is a single-value function.

For more information on the hyperbolic cosine function, see Cosh (Cosine,
Hyperbolic), page 422.

Syntax

Acosh(Argument)

Where:

Argument is a metric representing a list of real numbers with values greater


than or equal to 1.

Asin (Arc Sine)


Returns the arc sine of a given number as an angle. This angle is calculated
in radians and falls between - p /2 and p /2. To convert radians to degrees,
multiply by 180/ p . This is a single-value function.

Syntax

Asin(Argument)

Where:

Argument is a metric representing a list of real numbers. The values are the
values of the sine of the angles sought. These values must be between -1
and 1.

Asinh (Arc Sine, Hyperbolic)


Returns the inverse hyperbolic sine of a number. Asinh is the inverse of the
Sinh function. This is a single-value function.

Copyright © 2023 All Rights Reserved 417


Fu n ct io n s Refer en ce

For more information on the hyperbolic sine function, see Sinh (Sine,
Hyperbolic), page 436.

Syntax

Asinh(Argument)

Where:

Argument is a metric representing a list of real numbers.

Atan (Arc Tangent)


Returns the arc tangent of a given number as an angle. This angle is
specified in radians and falls between p /2 and- p/ 2. To convert from radians
to degrees, multiply by 180/ p.

Syntax

Atan(Number)

Where:

Number is the tangent of the angle you want.

Atan2 (Arc Tangent 2)


Returns the arc tangent of the specified x- and y-coordinates. The arc
tangent is the angle from the x-axis to a line containing the origin (0, 0) and
a point with coordinates (x_num, y_num). The angle is given in radians
between - p and p . To convert the result from radians to degrees, multiply by
180/ p . This is a single-value function.

Syntax

Atan2(x_num, y_num)

Where:

x_num is the x-coordinate of the point.

y_num is the y-coordinate of the point.

Copyright © 2023 All Rights Reserved 418


Fu n ct io n s Refer en ce

Atanh (Arc Tangent, Hyperbolic)


Returns the inverse hyperbolic tangent of a given number. Atanh is the
inverse of the Tanh function. This is a single-value function.

For more information on the hyperbolic tangent function, see Tanh (Tangent,
Hyperbolic), page 438.

Syntax

Atanh(Number)

Where:

Number is any real number between 1 and -1.

Ceiling (Ceiling Value)


Returns the closest integer greater than or equal to a given number.
Ceiling is often used as a rounding function. This is a single-value
function.

Syntax

Ceiling(Argument)

Where:

Argument is a metric representing a list of real numbers.

Example

Use ceiling calculations in situations where results are expressed as


specified units of measurement. For example, to avoid returns at the cent
level, Ceiling could be used on a product price to round up the figures to
the nearest dollar.

This simple example illustrates how the Ceiling function acts on positive
and negative numbers, and how the results compare to the use of the Floor
function.

Copyright © 2023 All Rights Reserved 419


Fu n ct io n s Refer en ce

Argument values Floor Ceiling

947.67 947.00 948.00

463.33 463.00 464.00

-947.67 -948.00 -947.00

-463.33 -464.00 -463.00

Combine (Combination)
The number of possible combinations for a given number of items selected
as a group from a set.

Syntax

Combine(Number, Number_Chosen)

Where:

Number is the number of items in a set.

Number_Chosen is the number of items to be included in each combination.

Expression

In the expression that follows, Number = n; Number_Chosen = k,

Where:

Usage Notes

Copyright © 2023 All Rights Reserved 420


Fu n ct io n s Refer en ce

In combination calculations, the internal order of the items selected does not
affect the return. This differs from the case of a permutation, in which the
order of the items selected does affect the return. Permutation is a statistical
function.

If an argument is not an integer, it is truncated.

This function returns an error value if:

l Either argument is nonnumeric

l n< 0

l k<0

l n £ k

Cos (Cosine)
This function takes the value of an angle in radians and returns the cosine of
the angle as a number between -1 and 1.

In a given right triangle containing an angle A, there are three sides: the side
opposite to A, the side adjacent to A, and the side opposite to the right angle
(hypotenuse). The cosine of A is the ratio of the lengths of the adjacent side
over the hypotenuse.

To convert degrees to radians, multiply by p/180. This is a single-value


function.

Syntax

Cos(Argument)

Where:

Argument is a metric representing a list of real numbers. The values are the
angles, in radians, for which the value of the cosine is sought. To convert
the result from radians to degrees, multiply by 180/p.

Copyright © 2023 All Rights Reserved 421


Fu n ct io n s Refer en ce

Cosh (Cosine, Hyperbolic)


Returns the hyperbolic cosine of a number. This is a single-value function.

Syntax

Cosh(Argument)

Where:

Argument is a metric representing a list of real numbers. The values are the
angles, in radians, for which the value of the hyperbolic cosine is sought. To
convert radians to degrees, multiply by 180/p.

Expression

Degrees (Conversion To)


Returns the value of an angle converted from radians to degrees. This is a
single-value function.

Syntax

Degrees(Argument)

Where:

Argument is a metric representing a list of values to be converted from


radians to degrees.

Example

These simple examples illustrate how the Degrees function converts an


angle entered in radians into degrees.

Copyright © 2023 All Rights Reserved 422


Fu n ct io n s Refer en ce

Function/Result Calculation

Degrees(2.27) = 130

Degrees( p/2 ) = 90

Exp (Exponent)
Returns the value e raised to the power of the number given. e is a
mathematical constant equal to 2.71828182845904. Exp is the inverse of
Ln, the natural logarithm of a number.

This is a single-value function.

For more information on the natural logarithm function, see Ln (Logarithm,


Natural), page 426.

Syntax

Exp(Argument)

Where:

Argument is a metric representing a list of real numbers. The values are the
power to which e is raised

Example

This simple example illustrates the results of using the Exp function. The
variable e=2.71828182845904

Function/Result Calculation

X = e2 ;
Exp (2) =
7.38905609893062 2.71828182845904 × 2.71828182845904 =
7.38905609893062

Copyright © 2023 All Rights Reserved 423


Fu n ct io n s Refer en ce

Factorial (Factorial)
Returns the factorial of a positive integer. The factorial of an integer N is
equal to the product of all integers from 1 to N. For example, the factorial of
5 is 1 × 2 × 3 × 4 × 5, or 120.

This is a single-value function.

Syntax

Factorial(Argument)

Where:

Argument is a metric representing a list of positive integers.

Usage Notes

If a number is not an integer or is negative, the function returns a NULL.

Example

These simple examples illustrate the results of using the Factorial function.

Function/Result Calculation

Factorial(5) = 120 5 × 4 × 3 × 2 × 1=120

1 × 2 × 3 = 6;
Factorial(Argument) = 6,
1 × 2 × 3 × 4 × 5 × 6 × 7 = 5040;
5040, 362880 where Argument
contains the values 3,7,9 1 ×2×3×4×5×6×7×8×9
= 362880

Floor (Floor Value)


Returns the closest integer less than or equal to a given number. Floor is
often used as a rounding function. This is a single-value function.

Syntax

Floor(Argument)

Copyright © 2023 All Rights Reserved 424


Fu n ct io n s Refer en ce

Where:

Argument is a metric representing a list of real numbers.

Example

These simple examples illustrate how the Floor function acts on positive
and negative numbers, and how the results compare to the use of the
Ceiling function.

Argument Values Floor Ceiling

947.67 947.00 948.00

463.33 463.00 464.00

-947.67 -948.00 -947.00

-463.33 -464.00 -463.00

Int (Integer)
Returns the integer part of a number rounded down to the nearest integer.
This is a single-value function.

Syntax

Int(Argument)

Where:

Argument is a metric representing a list of real numbers.

Usage Notes

The expression [Argument - INT(Argument)] can be used to return


the decimal part of a non-integer.

Results from Int and Trunc differ only when the values are less than 0.

Example

Copyright © 2023 All Rights Reserved 425


Fu n ct io n s Refer en ce

These simple examples illustrate how the Int function acts on positive and
negative numbers, and how the results differ from the Trunc function when
the numbers are negative.

Argument Values Int Trunc

947.67 947.00 947.00

463.33 463.00 463.00

-947.67 -948.00 -947.00

-463.33 -464.00 -463.00

Ln (Logarithm, Natural)
Returns the natural logarithm of a given number. This is a single-value
function. Ln is the inverse of the Exp function.

For more information on the Exponent function, see Exp (Exponent), page
423.

Syntax

Ln(Argument)

Where:

Argument is a metric representing a list of positive real numbers.

Example

This simple example illustrates the results of the Ln function. The variable
e=2.71828182845904.

Function/Result Calculation

Ln (20) = 20 = e x where x is the natural logarithm;


2.99573227355399 20 = e 2.99573227355399

Copyright © 2023 All Rights Reserved 426


Fu n ct io n s Refer en ce

Log (Logarithm)
Returns the logarithm of a given number in a specified base. This is a single-
value function.

Syntax

Log(Argument, Base)

Where:

Argument is a metric representing a list of positive real numbers.

Base is the base of the logarithm.

Example

This simple example illustrates the results of the Log function.

Function/Result Calculation

Log(9, 3) = 2 9 = 3 x where x is the base-3 logarithm; 9 = 3 2

Log(4, 4) = 1 4 = 4 x where x is the base-4 logarithm; 4 = 4 1

7776 = 6 x where x is the base-6 logarithm;


Log (7776, 6) = 5
7776 = 6 5

Log10 (Logarithm, Base 10)


Returns the base-10 logarithm of a given number. This is a single-value
function.

Syntax

Log10(Argument)

Where:

Argument is a metric representing a list of positive real numbers.

Example

Copyright © 2023 All Rights Reserved 427


Fu n ct io n s Refer en ce

This simple example illustrates the results of the Log10 function.

Function/Result Calculation

10000 = 10 x where x is the base-10


Log10(10000) = 4
logarithm; 10000 = 10 4

Mod (Modulus)
Returns the remainder of a number when divided by a another number. The
result has the same sign as the dividend. This is a single-value function.

Syntax

Mod (Argument, Divisor)

Where:

Argument is a metric representing a list of real numbers.

Divisor is the number used to divide the value(s) of Argument.

Usage Notes

The function returns a NULL if Divisor = 0.

Use the Quotient function to return only the integral part of the result.

Example

These simple examples illustrate the results of using the Mod function.

Function/Result Calculation

Mod(5, 2) = 1 5/2 = 2 remainder 1

5/-2 = 2 remainder 1 and takes the sign of


Mod(5, -2) = 1
the dividend

Mod(-5, 2) = -1 -5/2 = 2 remainder 1 and takes the sign of

Copyright © 2023 All Rights Reserved 428


Fu n ct io n s Refer en ce

Function/Result Calculation

the dividend

Mod(140, 2) = 0 140/2 = 70 remainder 0

Mod(83, 9) = 2 83/9 = 9 remainder 2

-5/-2 = 2 remainder 1 and takes the sign of


Mod(-5, -2) = -1
the dividend

Power
Returns the value of an input number raised to a given power. This is a
single-value function.

Syntax

Power(Argument, Power)

Where:

Argument is a metric representing a list of base numbers. All real numbers


are valid.

Power is the exponent to which Argument is raised.

Usage Notes

If Argument is a negative number and Power is an even number, the result is


positive; however, if Argument is negative and Power is an odd number, the
result is negative.

Example

These simple examples illustrate the results of using the Power function.

Copyright © 2023 All Rights Reserved 429


Fu n ct io n s Refer en ce

Function/Result Calculation

Power(5, 2) = 25 5 × 5 = 25

Power(-5, 2) = 25 -5 × -5 = 25

Power(-5, 3) = -125 -5 × -5 × -5 = -125

Power(4, 3) = 64 4 × 4 × 4 = 64

Power(20,4) =
20 × 20 × 20 × 20 = 160000
160000

Quotient
Returns the integer result of dividing two numbers. This function discards
the remainder. This is a single-value function.

Syntax

Quotient(numerator, denominator)

Where:

Numerator is a metric representing a list of real numbers to be used as the


dividend.

Denominator is a metric representing a list of real numbers to be used as


the divisor.

Usage Notes

Use the Mod function (Mod (Modulus), page 428) to retrieve only the
remainder.

Example

These simple examples illustrate the results of using the Quotient function.

Copyright © 2023 All Rights Reserved 430


Fu n ct io n s Refer en ce

Function/Result Calculation

Quotient(5, 2) = 2 5/2 = 2 remainder 1

Quotient(83, 9) = 9 83/9 = 9 remainder 2

Radians (Conversion To)


Returns the value of an angle converted from degrees to radians. This is a
single-value function.

Syntax

Radians(Argument)

Where:

Argument is a metric representing a list of values to convert from degrees


to radians.

Example

This simple example illustrates how the Radians function converts an angle
entered in degrees into radians.

Function/Result Calculation

Radians(130) = 2.27

Randbetween (Random Number Between Two Values)


Returns a random number that falls between two specified values. The value
returned is a real number, as opposed to an integer value.

A different number is returned each time the function is run. However, if the
Randbetween function is used to modify multiple rows of values on a report,
be aware that if you use a simple definition such as Randbetween(2, 10) the
same random number will be applied to each row of data on the report. You

Copyright © 2023 All Rights Reserved 431


Fu n ct io n s Refer en ce

can apply a different random number to each row of data in a report by


including metric values in the Randbetween calculation, and an example of
this is provided below.

Syntax

Randbetween(Bottom, Top)

Where:

Bottom is a real number or metric representing a list of real numbers that


are the lowest value(s) the function can return; the bottom of the range. You
can also include expressions that result in a real number value.

Top is a real number or metric representing a list of real numbers which are
the highest value(s) the function can return; the top of the range. You can
also include expressions that result in a real number value.

While Randbetween can accept real values as input values for Bottom and
Top, the input values are processed differently based on the following:

l Processed by the Analytical Engine: Functions provided with


MicroStrategy can be evaluated by the MicroStrategy Analytical Engine in
cases where functions cannot be evaluated by a database, or when
features such as derived metrics use a function as part of their definition.
When Randbetween is processed by the Analytical Engine, both input
values are rounded down to the nearest integer value before determining a
random number. For example, the expression Randbetween(0.5,1.6)
for a derived metric will first round both input values down, making the
resulting expression Randbetween(0,1). A random, real number is then
returned between the values of 0 and 1.

You can determine if a metric is processed by the Analytical Engine by


looking at the SQL view of a report.

l Processed by a database: Functions provided with MicroStrategy can be


passed to the database for processing when the database supports that

Copyright © 2023 All Rights Reserved 432


Fu n ct io n s Refer en ce

function. See Appendix A, MicroStrategy and Database Support for


Functions for a list of the databases and the functions they support.

When Randbetween is processed by a database, the real values can be


used directly as input values without any rounding. For example, the
expression Randbetween(0.5,1.6) for a metric will return a random,
real number between the values of 0.5 and 1.6.

Example

Random numbers are used often in statistical analysis. A common practice


is to apply a random percentage to another value. To do this, you can use
the Randbetween function to return a number between 0 and 1. This can be
achieved with the following syntax:

Randbetween(0, 1)

This returns a real number value between zero and one. This can be used in
an expression to multiply against another value, which would return a
random percentage of that value. For example, you can return a random
percentage of revenue by creating a metric with the following definition:

(Sum(Revenue) {~+} * Randbetween(0, 1))

When using a metric with this definition on a report the same random
percentage is applied to all revenue values on a report.

In the definition provided below, the metric Revenue is used in the


Randbetween calculation. By including the revenue data as part of the
calculation of Randbetween, a different random number is generated for
each row of revenue data on a report.

Randbetween(0, Revenue)

These two metrics are created as Random Revenue 1 and Random Revenue
2 respectively, and displayed on the same report shown below:

Copyright © 2023 All Rights Reserved 433


Fu n ct io n s Refer en ce

Notice that the metric Random Revenue 2, which includes the revenue data
as part of the Randbetween calculation, is using a different percentage for
each row of revenue data. However, the metric Random Revenue 1 which
uses a simple definition of the Randbetween calculation as Randbetween
(0,1) uses the same random percentage to modify all rows of Revenue
data.

Round (Round to Nearest Integer)


Returns the input values rounded to the nearest integer. This is a single-
value function.

Syntax

Round(Argument)

Where:

Argument is a metric representing a list of real numbers.

Example

These simple examples illustrate the result of using the Round function, and
compare them to the Int function results for the same values.

Argument Values Round Int

947.67 948.00 947.00

463.33 463.00 463.00

-947.67 -948.00 -948.00

-463.33 -463.00 -464.00

Copyright © 2023 All Rights Reserved 434


Fu n ct io n s Refer en ce

Round2 (Round to Specified Precision)


Returns the input values rounded to a specified number of digits. This is a
single-value function.

Syntax

Round2(Argument, Precision)

Where:

Argument is a metric representing a list of real numbers

Precision is an integer value specifying the placement of the digits to


which the Argument value(s) are rounded.

l If Precision = 0, then the values are rounded to the nearest integer. This
has the same results as using the Round function.

l If Precision is greater than 0, then the values are rounded to the


decimal place indicated.

l If Precision is less than 0, then the values are rounded to the specified
digits to the left of the decimal and starting to the left of the integer in the
ones place.

Example

This simple example illustrates how the Precision value affects the results of
the Round2 function.

Round2 Round2 Round2


Argument values
(argument, 0) (argument, 1) (argument, -1)

947.67 948.00 947.70 950.00

811.00 811.00 811.00 810.00

463.33 463.00 463.30 460.00

Copyright © 2023 All Rights Reserved 435


Fu n ct io n s Refer en ce

Sin (Sine)
This function takes the value of an angle in radians and returns the sine of
the angle as a number between -1 and 1.

In a given right triangle containing an angle A, there are three sides: the side
opposite to A, the side adjacent to A, and the side opposite to the right angle
(hypotenuse). The sine of A is the ratio of the lengths of the opposite side
over the hypotenuse.

To convert degrees to radians, multiply by p/180. This is a single-value


function.

Syntax

Sin(Argument)

Where:

Argument is a metric representing a list of values. The values are angles, in


radians, for which the sine is sought. Multiplying the argument by p/180
converts an angle from degrees to radians.

Sinh (Sine, Hyperbolic)


Returns the hyperbolic sine of a given angle. The value of the hyperbolic
sine is used to approximate a cumulative probability distribution. This is a
single-value function.

Syntax

Sinh(Argument)

Where:

Argument is a metric representing a list of values. The values are angles, in


radians, for which the hyperbolic sine is sought. Multiplying the argument by
p/180 converts an angle from degrees to radians.

Expression

Copyright © 2023 All Rights Reserved 436


Fu n ct io n s Refer en ce

Sqrt (Square Root)


Returns the square root of a given positive number. This is a single-value
function.

Syntax

Sqrt(Argument)

Where:

Argument is a metric representing a list of positive real numbers.

Usage Notes

A NULL is returned if an argument value is less than 0.

Example

This simple example illustrates the results of using the Sqrt function.

Sqrt(25) = 5

Sqrt(169) = 13

Tan (Tangent)
This function takes the value of an angle in radians and returns the tangent
of the angle.

In a given right triangle containing an angle A, there are three sides: the side
opposite to A, the side adjacent to A, and the side opposite to the right angle
(hypotenuse). The tangent of A is the ratio of the lengths of the opposite side
over the adjacent side.

To convert degrees to radians, multiply by p/180. This is a single-value


function.

Syntax

Copyright © 2023 All Rights Reserved 437


Fu n ct io n s Refer en ce

Tan(Argument)

Where:

Argument is a metric representing a list of real numbers.

Tanh (Tangent, Hyperbolic)


Returns the value of the hyperbolic tangent of a given number. This is a
single-value function.

Syntax

Tanh(Argument)

Where:

Argument is a metric representing a list of real numbers.

Expression

Trunc (Truncate)
Returns the integer component of a given number. The function removes the
fractional part of a real number so that only the integer part remains. The
fractional part is removed without rounding the number up or down. This is a
single-value function.

Syntax

Trunc(Argument)

Where:

Argument is a metric representing a list of real numbers.

Usage Notes

Results from Trunc and Int differ only when the values are less than 0.

Example

Copyright © 2023 All Rights Reserved 438


Fu n ct io n s Refer en ce

This simple example illustrates how the Trunc function acts on positive and
negative numbers, and how it differs from the Int function.

Argument Values Int Trunc

947.67 947.00 947.00

463.33 463.00 463.00

-947.67 -948.00 -947.00

-463.33 -464.00 -463.00

Statistical Functions
The statistical functions include a wide range of functions designed to
provide you with the tools to perform statistical analysis on your data.

AvgDev (Average Deviation)


Returns the average of the absolute deviations of a set of data points from
the mean. Similar to standard deviation, average deviation is a measure of
the variability in a data set.

Syntax

AvgDev <FactID> (Argument)

Where:

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Argument is a fact or metric representing a list of numbers.

Expression

Copyright © 2023 All Rights Reserved 439


Fu n ct io n s Refer en ce

In this expression, x is a value in a fact table.

Where:

is the average of all x i

BetaDistribution
Returns the cumulative Beta distribution of the variables alpha and beta,
where the probability density function is given by

Where:

This function is used to study percentage variations for an item across


population samples (for example, how much of a day people spend watching
television).

Syntax

BetaDistribution < Lower Bound, Upper Bound > (x, alpha, beta)

Where:

x is the value between Lower Bound (a) and Upper Bound (b) at which
the function is evaluated.

Copyright © 2023 All Rights Reserved 440


Fu n ct io n s Refer en ce

alpha and beta are distribution parameters.

l alpha =

l beta =

Lower Bound is an optional lower bound of the interval of x.

Upper Bound is an optional upper bound of the interval of x.

Usage Notes

The following conditions are invalid:

l x, alpha, or beta is nonnumeric.

l
alpha £ 0 or beta £ 0.
l x < Lower Bound or x > Upper Bound.

l Lower Bound = Upper Bound.

BinomialDistribution
Returns either the binomial probability or the cumulative binomial probability
of variables n and p. This function is used in cases in which:

l There is a fixed number of tests

l Each test can only result in either success or failure (binary)

l Tests are independent of all other tests

l The probability of success is constant, for example, to calculate the


probability that two out of the next three babies will be male

Syntax

BinomialDistribution <Cumulative> (x, n, p)

Where:

x is the number of successes.

n is the number of tests.

Copyright © 2023 All Rights Reserved 441


Fu n ct io n s Refer en ce

p is the number indicating the probability of a success in each trial.

Cumulative is a logical value that determines the form of the function.

l If Cumulative=0, it computes the Cumulative Binomial probability.

l If Cumulative=1, it computes the Binomial probability.

Expression

For the binomial probability:

Where:

is Combine(n, x).

The cumulative binomial distribution is:

Usage Notes

If x or n is not an integer, it is truncated.

The following conditions are invalid:

l One of the arguments is nonnumeric.

l x>n

l x< 0

l p < 0 or p > 1

Copyright © 2023 All Rights Reserved 442


Fu n ct io n s Refer en ce

ChiSquareDistribution
Returns the right-tailed chi-squared distribution of the degrees of freedom,
where the probability density function is given by

Where:

is the degree of freedom

is the gamma function

The chi-squared distribution is associated with a chi-squared test. A chi-


squared test is used to compare observed values against expected ones. It
determines the validity of a hypothesis, such as the prediction that the next
generation of a certain plant hybrid will exhibit a specific combination of
colors.

Syntax

ChiSquareDistribution(x, df)

Where:

x is a non-negative decimal value at which the distribution is evaluated.

df is an integer greater than or equal to one (>=1) indicating the number of


degrees of freedom for the distribution.

Usage Notes

If df is not an integer, it is truncated

The following conditions are invalid:

Copyright © 2023 All Rights Reserved 443


Fu n ct io n s Refer en ce

l Either argument is nonnumeric

l x < 0

l df < 1

ChiSquareTest (Chi-Square Test for Goodness of Fit)


Returns the result of a test for goodness of fit. This function returns the chi-
squared distribution for a statistical value and its associated degrees of
freedom to determine, for example, to what extent an experiment verifies
hypothesized results.

Reality: H 0 is Reality: H 1 is
Decision
correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is a probability of making a Type 2 error.

ChiSquareTest returns the p-value for the hypothesis test in the following
form:

l H 0 : Argument1 and Argument2 come from the same distribution.

l H 1 : Argument1 and Argument2 come from different distributions.

Syntax

ChiSquareTest(Argument1, Argument2)

Where:

Copyright © 2023 All Rights Reserved 444


Fu n ct io n s Refer en ce

Argument1 is a fact or metric representing a list of values that contains


observed values, which are to be tested against expected values.

Argument2 is a fact or metric representing a list of expected values, which


are compared against the observed values provided by Argument1.

Usage Notes

This function returns the probability for a chi-squared (x 2 ) statistic and its
associated degrees of freedom (df).

This function results in an invalid value if Argument1 and Argument2 have


a different number of data points. Meaning, each observed value must have
an expected value to be compared to.

Confidence (Confidence Interval)


Returns the confidence interval for a population mean. The confidence
interval is a range of values on either side of a mean. For example, if you
order a product through the mail, you can determine, within a given level of
confidence, the earliest and latest date of expected arrival.

Syntax

Confidence(Alpha, Stdev, Size)

Where:

Alpha is the level of significance at which confidence is computed.

Stdev is the standard deviation of the population for the given data range.

Size is a positive integer indicating the size of the sample.

Expression

The confidence level is expressed as [100(1-alpha)%]. If alpha = 0.05, then:

l Confidence = 95%

l The area equivalent to 95% of the population = 1.96

Copyright © 2023 All Rights Reserved 445


Fu n ct io n s Refer en ce

l The confidence interval is

Usage Notes

If size is not an integer, it is truncated.

The following conditions are invalid:

l One of the arguments is nonnumeric.

l alpha < 0 or alpha > 1

l stdev < 0

l size < 1

Example

For an example of the Confidence function, see Confidence Level Example,


page 91.

Correlation
A correlation of two values describes the degree to which the values are
related or associated. Values that are closely related with either a positive
or negative correlation will have a correlation close to 1 or -1 respectively,
while values that are not correlated at all will have a correlation close to 0.

To determine the correlation of two values while applying a weight to the


comparisons, see WeightedCorr (Weighted Correlation), page 254.

This function is the same as Pearson (Pearson Product Moment Correlation


Coefficient), page 479.

Syntax

Correlation <FactID> (Argument1, Argument2)

Where:

Copyright © 2023 All Rights Reserved 446


Fu n ct io n s Refer en ce

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Argument1 and Argument2 are lists of values represented by facts or


metrics.

Usage Notes

The correlation coefficient is measured on a scale that varies from + 1


through 0 to - 1. So only a value between -1 and 1 is returned.

Complete correlation between two variables is expressed by either + 1 or -1.


When one variable increases as the other increases, the correlation is
positive; when one decreases as the other increases, the correlation is
negative. Complete absence of correlation is represented by 0.

If an array or reference argument contains text, logical values, or empty


cells, those values are ignored; however, cells with the value zero are
included.

If Argument1 and Argument2 have a different number of data points,


Correlation returns an error.

If either Argument1 or Argument2 is empty, or if the standard deviation of


their values equals zero, Correlation returns an error.

Covariance
Covariance is used to examine the relationship between two data sets. For
instance, the covariance could be used to examine whether an increase in
income is related to higher education levels. A covariance greater or less
than zero indicate a relationship, while a value of zero indicates no
relationship.

To determine the covariance of two values while applying a weight to the


comparisons, see WeightedCov (Weighted Covariance), page 257.

Covariance is similar to Correlation and Pearson, which also describe


the relationship between two data sets. While Covariance describes the

Copyright © 2023 All Rights Reserved 447


Fu n ct io n s Refer en ce

relationships with positive or negative values, Correlation and Pearson


normalize these positive or negative values to a range between -1 and 1.

Syntax

Covariance <FactID> (Argument1, Argument2)

Where:

Argument1 and Argument2 are facts or metrics representing lists of


values.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

In the expression that follows:

l Argument1 = X

l Argument2= Y

Where:

= average value of x

= average value of y

Usage Notes

The following conditions are invalid:

l Argument1 and Argument2 do not contain the same number of data points.

l Either value set is empty.

Copyright © 2023 All Rights Reserved 448


Fu n ct io n s Refer en ce

CritBinomial (Criterion Binomial)


Returns the smallest value for which the cumulative binomial distribution is
greater than or equal to a criterion value. Use this function for quality
control, for example, to determine the maximum number of defective items
that can come off an assembly line run before rejecting an entire lot.

Syntax

CritBinomial(Trials, Probability_s, Alpha)

Where:

Trials is the number of Bernoulli trials.

Probability_s is the probability of a success on each trial.

Alpha is the criterion value.

Usage Notes

The following conditions are invalid:

l Any argument is nonnumeric.

l Trials is not an integer.

l Trials < 0

l Probability_s is < 0 or probability_s > 1

l alpha < 0 or alpha > 1

ExponentialDistribution
Returns either the probability density or the cumulative distribution of a
random variable. This function is used to model the time between events.
For example, it can be used to estimate the probability that an automatic-
teller machine will take no more than one minute to deliver requested cash.

Syntax

ExponentialDistribution <Cumulative> (x, lambda)

Copyright © 2023 All Rights Reserved 449


Fu n ct io n s Refer en ce

Where:

Cumulative is a logical value that determines the form of the function:

l If Cumulative=0 (default), it returns the cumulative distribution.

l If Cumulative=1, it returns the probability density.

x is the value of the function.

lambda is the value of the parameter.

Expression

For probability density:

For cumulative distribution:

Usage Notes

The following conditions are invalid:

l Either x or lambda is nonnumeric

l x<0

l
lambda £ 0

Fisher (Fisher Transformation)


Returns the Fisher transformation at x. The Fisher transformation yields a
normally-distributed function, as opposed to a skewed one. It is used to
perform hypothesis-testing on the correlation coefficient.

Syntax

Fisher (x)

Copyright © 2023 All Rights Reserved 450


Fu n ct io n s Refer en ce

Where:

x is the number for which the transformation is sought.

Expression

Usage Notes

The following conditions are invalid:

l x is nonnumeric.

l
x £ -1 or x ³ 1.

FDistribution (F-Probability Distribution)


Returns the right-tailed distribution (F-probability) of a random variable. This
function is used to determine the difference, in degrees of diversity, between
two data sets. For example, test scores administered to males and females
entering high school can be examined using this function to determine
whether the variability in females is different from that found in males.

Syntax

FDistribution(x, df1, df2)

Where:

x is the value at which the function is evaluated.

df 1 represents the degrees of freedom of numerator values.

df 2 represents the degrees of freedom of denominator values.

Expression

Where:

Copyright © 2023 All Rights Reserved 451


Fu n ct io n s Refer en ce

F is a random variable that has an F distribution.

Usage Notes

If df 1 or df 2 is not an integer, it is truncated.

The following conditions are invalid:

l An argument is non-numeric

l x<0

l df 1 < 1

l df 2 < 1

Forecast
The Forecast function uses data recorded for certain time periods to
calculate and display the expected value of data for an unknown time period.
This is most commonly used to predict future metric values based on
historical data. For example, based on revenue data for three years, you
want to predict what your Revenue will be for the coming year.

This function uses a linear equation to predict future values. Therefore, it is


best suited to predict values that increase or decrease in a linear trend. For
example, if your profits are increasing by $10,000 each year, this is a
scenario that is well suited for a prediction based on a linear equation.

For a function that predicts values in a similar way for data that is increasing
or decreasing exponentially, see Growth, page 458.

Syntax

Forecast <FactID>(FutureTime, KnownData1,...,KnownDataN,


KnownTimeIntervals1,...,KnownTimeIntervalN)

Where:

FutureTime is the point in time for which to predict the data. This is
commonly defined as an integer. For example, to predict values for the year

Copyright © 2023 All Rights Reserved 452


Fu n ct io n s Refer en ce

2009, you would enter the value 2009 for FutureTime (this assumes your
year data is defined with IDs that match the year).

KnownData1,...,KnownDataN are separate scalar values that provide


the data to use to predict a future value for. While you can use Forecast to
enter these values manually, it is more common to use ForecastV which
can use a metric to enter a list of values, as described in ForecastV
(Forecast, Vector Input), page 453.

KnownTimeIntervals1,...,KnownTimeIntervalN are separate scalar


values that provide the time intervals for which data is known. While you can
use Forecast to enter these values manually, it is more common to use
ForecastV which can use an attribute to enter a list of time intervals, as
described in ForecastV (Forecast, Vector Input), page 453.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Example

As described in the syntax requirements, you can use Forecast to enter


values and time intervals manually. However, it is more common to use
ForecastV to use metrics and attributes to enter this information, as
described in ForecastV (Forecast, Vector Input), page 453.

ForecastV (Forecast, Vector Input)


The ForecastV function uses data recorded for certain time periods to
calculate and display the expected value of data for an unknown time period.
This is most commonly used to predict future metric values based on
historical data. For example, based on revenue data for three years, you can
predict what your Revenue will be for the coming year.

You can use ForecastV to predict values for any point in time, including
dates that have known data. However, this type of function is meant for
predicting future, unknown values.

Copyright © 2023 All Rights Reserved 453


Fu n ct io n s Refer en ce

This function uses a linear equation to predict future values. Therefore, it is


best suited to predict values that are increasing or decreasing in a linear
trend. For example, if your profits are increasing by $10,000 each year, this
is a scenario that is well suited for a prediction based on a linear equation.

For a function that predicts values in a similar way for data that is increasing
or decreasing exponentially, see GrowthV (Growth, Vector Input), page 459.

Syntax

ForecastV <FactID>(FutureTime, KnownData, KnownTimeIntervals)

Where:

FutureTime is the point in time for which to predict the data. This is
commonly defined as an integer. For example, to predict values for the year
2009, you would enter the value 2009 for FutureTime (this assumes your
year data is defined with IDs that match the year).

KnownData is an object representing a list of values. This list of values is


the known data to use to predict a future value for. KnownData is commonly
used for metrics that represent data such as revenue, profit, and so on.

KnownTimeIntervals is an object representing a list of values. This list


of values provide the time intervals for which data is known.
KnownTimeIntervals is commonly used for attributes that represent
intervals of time such as year, quarter, month, and so on.

Since this function allows you to enter a list of time intervals, it can account
for missing time intervals more accurately than the TrendV function (see
TrendV (Trend, Vector Input), page 488). For an example, see the examples
described below.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Example

Copyright © 2023 All Rights Reserved 454


Fu n ct io n s Refer en ce

The ForecastV function is useful to display predicted future values of a


metric as a subtotal of the metric on a report.

For example, in the MicroStrategy Tutorial project a new subtotal named


2008 Forecast can be created with the following definition:

ForecastV(2008, x, Year)

Since this is in a subtotal, the x is a placeholder for a metric. When a


subtotal is applied to a metric on a report, the placeholder inputs that
metric’s values.

Also, 2008 is used for the period in time to predict metric data for because
the Year attribute uses ID values that match the year.

After making the new custom subtotal available for the Revenue metric (see
the Advanced Reporting Guide for steps to make custom subtotals available
for metrics) a report with the attribute Year and the metric Revenue is
created. When the 2008 Forecast is displayed on the report, it displays the
predicted value for 2008 Revenue, as shown below:

Since the ForecastV function allows you to enter a list of time intervals, it
can account for time intervals that you have no data for. For example,
consider the same report in a scenario in which there was no data available
for the year 2006. The ForecastV function can still use the two available
years to predict the revenue for 2008.

Copyright © 2023 All Rights Reserved 455


Fu n ct io n s Refer en ce

FTest
Returns the P-value of an F-test on the variances of two sets of data. It tests
that the variances in the two sets are not significantly different. For example,
given the test scores from public and private schools, this function enables
you to determine whether diversity levels between the two school types are
significantly different.

Decision Reality: H 0 is Reality: H 1 is


correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is basically a probability of making a Type 2 error.

FTest returns the p-value for the hypothesis test in the following form:

l :

l :

Copyright © 2023 All Rights Reserved 456


Fu n ct io n s Refer en ce

Syntax

FTest <Hypothesis type, Ratio> (Argument1, Argument2)

Usage Notes

The following conditions are invalid:

l Argument1 and Argument2 contain a different number of data points

l The variance of either data set is zero

GammaDistribution
Returns either the cumulative Gamma distribution or the probability density
of a random variable. This function is used in queueing analysis to study
variables that may have a skewed distribution.

Syntax

GammaDistribution <Cumulative> (x, Alpha, Beta)

Where:

x is the value at which you want to evaluate the distribution.

Alpha is a distribution parameter.

Beta is a distribution parameter.

Cumulative is a logical value that determines the form of the function:

l If Cumulative=0 (default), it returns the cumulative distribution.

l If Cumulative=1, it returns the probability density.

Expression

Copyright © 2023 All Rights Reserved 457


Fu n ct io n s Refer en ce

The expression for the standard gamma distribution is:

If alpha = 1, this function returns the exponential distribution as:

Usage Notes

When alpha > 0, this function is also known as the Erlang distribution.

The following conditions are invalid:

l Either alpha or beta is nonnumeric

l
Either alpha £ 0 or beta £ 0
l x<0

Growth
The Growth function uses data recorded for certain time intervals to
calculate and display the expected value of data for an unknown time period.
This is most commonly used to predict future metric values based on
historical data. For example, based on revenue data for three years, you can
predict what your Revenue will be for the coming year.

This function uses an exponential equation to predict future values.


Therefore, it is best suited to predict values that increase or decrease in an
exponential trend. For example, if your profits are increasing by 4 percent
each year, this is a scenario that is well suited for a prediction based on an
exponential equation.

Copyright © 2023 All Rights Reserved 458


Fu n ct io n s Refer en ce

For a function that predicts values in a similar way for data that is increasing
or decreasing with a linear trend, see Forecast, page 452 or Trend, page
487.

Syntax

Growth <FactID>
(KnownData1,...,KnownDataN, FutureTimeOffset)

Where:

KnownData1,...,KnownDataN are separate scalar values that provide the


data to use to predict a future value for. While you can use Growth to enter
these values manually, it is more common to use GrowthV which can use a
metric to enter a list of values, as described in GrowthV (Growth, Vector
Input), page 459.

FutureTimeOffset is the point in time after the final time interval


available for which to predict the data. This is commonly defined as an
integer. For example, to predict values for the year 2009 when the last
available data you have is for 2007, you would enter the value of 2 for
FutureTimeOffset.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Example

As described in the syntax requirements, you can use Growth to enter


values manually. However, it is more common to use GrowthV to use
metrics and attributes to enter this information, as described in GrowthV
(Growth, Vector Input), page 459.

GrowthV (Growth, Vector Input)


The GrowthV function uses data recorded for certain time intervals to
calculate and display the expected value of data for an unknown time period.
This is most commonly used to predict future metric values based on

Copyright © 2023 All Rights Reserved 459


Fu n ct io n s Refer en ce

historical data. For example, based on revenue data for three years, you
want to predict what your Revenue will be for the coming year.

You can use GrowthV to predict values for any point in time, including
dates that have known data. However, this type of function is meant for
predicting future, unknown values.

This function uses an exponential equation to predict future values.


Therefore, it is best suited to predict values that increase or decrease in an
exponential trend. For example, if your profits are increasing by 15 percent
each year, this is a scenario that is well suited for a prediction based on a
linear equation.

For a function that predicts values in a similar way for data that is increasing
or decreasing with a linear trend, see ForecastV (Forecast, Vector Input),
page 453 or TrendV (Trend, Vector Input), page 488.

Syntax

GrowthV <FactID, SortBy>(KnownData, FutureTimeOffset)

Where:

KnownData is an object representing a list of values. This list of values is


the known data to use to predict a future value for. KnownData is commonly
used for metrics that represent data such as revenue, profit, and so on.

FutureTimeOffset is the point in time after the final time interval


available for which to predict the data. This is commonly defined as an
integer. For example, to predict values for the year 2009 when the last
available data you have is for 2007, you would enter the value of 2 for
FutureTimeOffset.

The GrowthV function assumes that data is available for sequential time
intervals with no missing data. If your data meets these requirements, this
allows you to use a single expression to use on reports with varying time
intervals such as year, month, quarter, and so on. For an example, see the
examples described below.

Copyright © 2023 All Rights Reserved 460


Fu n ct io n s Refer en ce

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

SortBy is a parameter that defines the order of calculation. For more


information, see BreakBy and SortBy Parameters, page 27.

Example

The GrowthV function is useful to display predicted future values of a metric


as a subtotal of the metric on a report.

For example, in the MicroStrategy Tutorial project a new subtotal named


2008 Growth can be created with the following definition:

GrowthV(x, 1)

Since this is in a subtotal, the x is a placeholder for a metric. When a


subtotal is applied to a metric on a report, the placeholder inputs that
metric’s values.

Also, 1 is used as the offset in the time interval to predict data for the first
time interval that is not known.

After making the new custom subtotal available for the Revenue metric (see
the Advanced Reporting Guide for steps to make custom subtotals available
for metrics) a report with the attribute Year and the metric Revenue is
created. When the 2008 Growth is displayed on the report, it displays the
predicted value for 2008 Revenue, as shown below:

This predicted value is different than the values predicted by the functions
ForecastV and TrendV, as described in ForecastV (Forecast, Vector
Input), page 453 and TrendV (Trend, Vector Input), page 488. This
difference is due to GrowthV predicting values based on an exponential
trend, and as such should be used with data that reflects such a trend.

Copyright © 2023 All Rights Reserved 461


Fu n ct io n s Refer en ce

HeteroscedasticTTest and HomoscedasticTTest


Return the P-value for the hypothesis test. These two functions are used to
determine the level of variance between the means of paired samples,
assuming both samples have different arguments. For example, they may be
used when a given group is to be tested before and after an experiment.

Decision Reality: H 0 is Reality: H 1 is


correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is a probability of making a Type 2 error.

HeteroscedasticTTest or HomoscedasticTTest returns the p-value for the


hypothesis test in the following form:

l For H 0 :

l For H 1 :

Copyright © 2023 All Rights Reserved 462


Fu n ct io n s Refer en ce

Syntax

HeteroscedasticTTest or HomoscedasticTTest <Hypothesis type,


offset> (Argument1, Argument2)

Usage Notes

Heteroscedastic t-tests are based on the assumption that variances between


two sample data ranges are unequal [σ 2 (Argument1) ¹ σ 2 (Argument2)].

Homoscedastic t-tests are based on the assumption that variances between


two sample data ranges are equal [σ 2 (Argument1) = σ 2 (Argument2)].

The following conditions are invalid:

l Argument1 and Argument2 have a different number of data points, and


Hypothesis type = 1 (paired).

l Offset or Hypothesis type is nonnumeric.

Example

For an example using both Heteroscedastic T-test and Homoscedastic T-


test, see Hypothesis Testing Example, page 83.

HypergeometricDistribution
Returns the probability of a given number of sample successes, given the
sample size, population successes, and population size. Use this function
for problems with a finite population, where each observation is either a
success or a failure, and where each subset of a given size is chosen with
equal likelihood.

Syntax

HypergeometricDistribution(x, n, M, N)

Copyright © 2023 All Rights Reserved 463


Fu n ct io n s Refer en ce

Where:

x is the number of successes in the sample.

n is the size of the sample.

M is the number of successes in the population.

N is the population size.

Expression

Usage Notes

All arguments are truncated to integers.

The following conditions are invalid:

l Any argument is nonnumeric

l x < 0 or x is greater than the lesser of n or M

l x is less than the larger of 0 or (n - N + M)

l n < 0 or n > N

l M < 0 or M > N

l N<0

Intercept
Returns the point at which a line intersects the y-axis in a graph. This
function is used to determine the value of a dependent variable Y when the
value of its associated independent variable X is 0. The point of intersection
is based on a best-fit regression line plotted through available values of X
and Y.

Copyright © 2023 All Rights Reserved 464


Fu n ct io n s Refer en ce

Syntax

Intercept <FactID> (Argument1, Argument2)

Where:

Argument1 is the dependent set of observation data represented by a fact


or metric.

Argument2 is the independent set of observation data represented by a fact


or metric.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

In the expressions that follow, Argument1 = Y, Argument2 = X.

The equation for the intercept of the regression line is

The slope of the regression line is calculated as:

Usage Notes

This function results in an invalid value if Argument1 and Argument2 contain


a different number of data points.

Example

For an example using the Intercept function, see Hypothesis Testing


Example, page 83.

Copyright © 2023 All Rights Reserved 465


Fu n ct io n s Refer en ce

InverseBetaDistribution (Inverse of the Beta Distribution)


Returns the inverse of the cumulative Beta distribution.

For information on the Beta distribution function, see BetaDistribution, page


440.

Syntax

InverseBetaDistribution <Lower Bound, Upper Bound> (x, Alpha,


Beta)

Where:

x is a probability associated with the beta distribution.

Alpha and Beta are distribution parameters.

Lower Bound is an optional lower bound of the interval of x.

Upper Bound is an optional upper bound of the interval of x.

Usage Notes

The following conditions are invalid:

l x, alpha, or beta is nonnumeric

l
alpha £ 0 or beta £ 0
l
x £ 0 or x ³ 1
l x < Lower Bound or x > Upper Bound

l Lower Bound > Upper Bound

InverseChiDistribution (Inverse of Chi-Squared Distribution)


Returns the inverse of the given right-tailed Chi-squared distribution greater
than or equal to a pre-specified value. This function is used to compare
observed results against expected ones to assess the validity of a
hypothesis.

Copyright © 2023 All Rights Reserved 466


Fu n ct io n s Refer en ce

For information on the Chi-squared function, see ChiSquareDistribution,


page 443.

Syntax

InverseChiDistribution(x, df)

Where:

x is the probability associated with a given chi-squared distribution.

df is the number of degrees of freedom for the distribution.

Usage Notes

If df is not an integer, it is truncated

The following conditions are invalid:

l Either argument is nonnumeric

l x < 0 or x >1

l df < 1

InverseFisher (Inverse of the Fisher Transformation)


Returns the inverse of the Fisher transformation. This function is used to
analyze correlations between data arrays.

For information on the Fisher transformation function, see Fisher (Fisher


Transformation), page 450.

Syntax

InverseFisher(x)

Where:

x is the value for which the inverse of the Fisher transformation is


performed.

Expression

Copyright © 2023 All Rights Reserved 467


Fu n ct io n s Refer en ce

Usage Notes

This function results in an invalid value if x is nonnumeric.

InverseFDistribution (Inverse of F-Probability Distribution)


Returns the inverse of the F probability distribution. This function is used to
return critical values from the F distribution. For example, the output of an
analysis-of-variation (anova) calculation may include data for F-statistic, F-
probability, and F-critical values at the 0.05 level of significance. In such
cases, the significance level can be used as the probability argument for
FINV to return the critical value of F.

For information on the F probability distribution function, see FDistribution


(F-Probability Distribution), page 451.

Syntax

InverseFDistribution (x, df1, df2)

Where:

x is the probability associated with the F right-tailed distribution.

df 1 represents the degrees of freedom of numerator values.

df 2 represents the degrees of freedom of denominator values.

Usage Notes

If df 1 or df 2 is not an integer, it is truncated.

The following conditions are invalid:

l An argument is nonnumeric

l x< 0 or x > 1

Copyright © 2023 All Rights Reserved 468


Fu n ct io n s Refer en ce

l df 1 < 1

l df 2 < 1

InverseGammaDistribution (Inverse of Gamma Distribution)


Returns the inverse of the cumulative Gamma distribution.

For more information on the cumulative Gamma distribution function, see


GammaDistribution, page 457.

Syntax

InverseGammaDistribution (x, Alpha, Beta)

Where:

x is the value at which you want to evaluate the distribution.

Alpha is a distribution parameter.

Beta is a distribution parameter.

Usage Notes

The following conditions are invalid:

l Either alpha or beta is nonnumeric

l
Either alpha £ 0 or beta £ 0
l x < 0 or x > 1

InverseLognormalDistribution (Inverse of Lognormal


Distribution)
Returns the inverse of the lognormal cumulative distribution. Ln(x) is
normally distributed using mean and standard deviation as parameters.

For more information on the lognormal cumulative distribution function, see


LognormalDistribution, page 473.

Syntax

InverseLognormalDistribution(x, Mean, Stdev)


Copyright © 2023 All Rights Reserved 469
Fu n ct io n s Refer en ce

Where:

x is the probability associated with the lognormal distribution.

Mean is the mean of ln(x).

Stdev is the standard deviation of ln(x).

Expression

In the expression that follows, mean = m, stdev =s.

Usage Notes

The following conditions are invalid:

l One of the arguments is nonnumeric

l x<0

l x>1

l stdev < 0

InverseNormDistribution (Inverse of Normal Cumulative


Distribution)
Returns the inverse of the normal cumulative distribution for a given mean
and standard deviation.

For more information on the normal cumulative distribution function, see


NormalDistribution (Normal Cumulative Distribution), page 476.

Syntax

InverseNormDistribution(x, Mean, Stdev)

Where:

Copyright © 2023 All Rights Reserved 470


Fu n ct io n s Refer en ce

x is the probability corresponding to a given normal distribution.

Mean is the arithmetic mean of the distribution.

Stdev is the standard deviation of the distribution.

Usage Notes

If mean = 0 and stdev = 1, this function returns the standard normal


distribution

The following conditions are invalid:

l One of the arguments is nonnumeric.

l stdev £ 0.

InverseNormSDistribution (Inverse of Standard Normal


Cumulative Distribution)
Returns the inverse, or critical value, of the cumulative standard normal
distribution. This function computes the critical value so that the cumulative
distribution is greater than or equal to a pre-specified value.

For more information on the cumulative standard normal distribution


function, see StandardNormalDistribution (Standard Normal Cumulative
Distribution), page 485.

Syntax

InverseNormSDistribution(x)

Where:

x is the probability corresponding to the normal distribution.

Usage Notes

The following conditions are invalid:

l x is nonnumeric.

l x < 0 or x > 1.

Copyright © 2023 All Rights Reserved 471


Fu n ct io n s Refer en ce

InverseTDistribution (Inverse of T-Distribution)


Returns the inverse of the right-tailed T-distribution.

For more information on the right-tailed T-distribution function, see


TDistribution, page 486.

Syntax

InverseTDistribution(Probability, df)

Where:

Probability is the probability associated with the t-distribution.

df is a value that indicates the degrees of freedom of the distribution.

Expression

Where:

X is a random value that follows the t-distribution.

Usage Notes

If df is not an integer, it is truncated.

The following conditions are invalid:

l Either probability or df is nonnumeric

l Probability < 0 or probability > 1

l df < 1

Kurtosis
Returns the kurtosis, which is a measure of whether the data is heavy or
light-tailed relative to a normal distribution. Datasets with high kurtosis tend
to have heavy tails, or outliers. Datasets with low kurtosis tend to have light
tails, or lack of outliers.

Copyright © 2023 All Rights Reserved 472


Fu n ct io n s Refer en ce

Syntax

Kurtosis <FactID> (Argument)

Where:

Argument is a set of values represented by a fact or metric.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

In the expression that follows, s is the sample standard deviation.

LognormalDistribution
Returns the lognormal cumulative distribution of a random variable X, where
the logarithm of X is normally distributed. LognormalDistribution takes
mean and standard deviation as parameters. This function is used to
analyze data that has been logarithmically transformed.

Syntax

LognormalDistribution(x, Mean, Stdev)

Where:

x is the value at which the function is evaluated.

Mean is the mean of ln(x).

Stdev is the standard deviation of ln(x).

Expression

In the expression that follows, mean = m, stdev = s.

Usage Notes

Copyright © 2023 All Rights Reserved 473


Fu n ct io n s Refer en ce

The following conditions are invalid:

l One of the arguments is nonnumeric

l
x £0
l
stdev £ 0

MeanTTest (Mean T-test)


Calculates the P-value of a T-test that tests the mean of the data against a
particular value. This function is used to determine the closeness in the
value of the means of two samples coming from the same population.

Decision Reality: H 0 is Reality: H 1 is


correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is basically a probability of making a Type 2 error.

MeanTTest returns the p-value for the hypothesis test in the following form:

l For H 0 :

l For H 1 :

Copyright © 2023 All Rights Reserved 474


Fu n ct io n s Refer en ce

Syntax

MeanTTest <Hypothesis type> (Argument, Hypothesis mean)

Where:

Argument is the value or list of values, represented by a fact or metric, that


contains sample data.

Hypothesis mean is m 0 .

Hypothesistype denotes the type of t-test to be performed. Hypothesis


type can be -1, 0, 1, or 2.

NegativeBinomialDistribution
This function determines the probability that there will be F failures before
the Nth success (S) with a constant probability of success P. The negative
binomial distribution is similar to the binomial distribution, but the number of
successes is fixed and the number of trials is variable.

As in the binomial distribution, trials are assumed to be independent. For


example, to find ten individuals with excellent reflexes, knowing that the
probability that a candidate has these qualifications is 0.3, this function
calculates the probability that a certain number of unqualified candidates
will be interviewed before the ten people sought are selected.

Syntax

NegativeBinomialDistribution(F, S, P)

Where:

F is the number of failures.

S is the threshold number of successes.

P is the probability of a success.

Copyright © 2023 All Rights Reserved 475


Fu n ct io n s Refer en ce

Expression

In the expression that follows, F = x, S = r.

Usage Notes

If either F or S is not an integer, it is truncated.

The following conditions are invalid:

l One of the arguments is nonnumeric.

l P< 0 or P> 1.

l
F + (S - 1) £ 0.

NormalDistribution (Normal Cumulative Distribution)


Calculates the normal distribution of the mean and standard deviation of a
set of values. Returns either the cumulative distribution or the probability
density. This function is widely applied in statistics, including in the area of
hypothesis testing.

Syntax

NormalDistribution <Cumulative> (x, Mean, Stdev)

Where:

x is the value for which the distribution is sought.

Mean is the arithmetic mean of the distribution.

StDev is the standard deviation of the distribution.

Cumulative is a logical value that determines the form of the function:

l If Cumulative=0 (default), it returns the cumulative distribution.

l If Cumulative=1 it returns the probability density.

Copyright © 2023 All Rights Reserved 476


Fu n ct io n s Refer en ce

Expression

In the expression that follows, z = x, mean = m, stdev = s.

Usage Notes

The following conditions are invalid:

l Either mean or stdev is nonnumeric

l Stdev £ 0

If mean = 0 and stdev = 1, the function returns the standard normal


distribution.

PairedTTest (Paired T-test, Two-Sample for Means)


Calculates the P-value of a T-test on the means of two paired sets of data.
Two-sample analyses are used to determine the level of variance between
the means of paired samples.

Decision Reality: H 0 is Reality: H 1 is


correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is basically a probability of making a Type 2 error.

Copyright © 2023 All Rights Reserved 477


Fu n ct io n s Refer en ce

PairedTTest returns the P-value for the hypothesis test in the following
form:

l H0:

l H1:

Syntax

PairedTTest <Type, Offset> (Argument1, Argument2)

Where:

Argument1 is a fact or metric representing a set of sample values.

Argument2 is a fact or metric representing a set of sample values.

Type is a logical value that determines the form of the function.

Usage Notes

One of the results of this sample is pooled variance, an accumulated


measure of spread data about the mean. Pooled variance is calculated as:

Copyright © 2023 All Rights Reserved 478


Fu n ct io n s Refer en ce

Pearson (Pearson Product Moment Correlation Coefficient)


This function returns the Pearson product moment correlation coefficient of
a set of values. The coefficient is a dimensionless index that ranges from -
1.0 to 1.0 (inclusive). It is used to determine the extent of a relationship
between two data sets.

Syntax

Pearson <FactID> (Argument1, Argument2)

Where:

Argument1 is a list of independent values represented by a fact or metric.

Argument2 is a list of dependent values represented by a fact or metric.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

In the expression that follows, Argument1 = X, Argument2 = Y.

Usage Notes

The following conditions are invalid:

l Either Argument1 or Argument2 contains one or more null values

l Argument1 and Argument2 contain a different number of data points

Permut (Permutation)
Returns the number of possible permutations for a given number of items
selected as a group from a set.In permutation calculations, the internal order
of the items selected affects the return. This differs from calculations of

Copyright © 2023 All Rights Reserved 479


Fu n ct io n s Refer en ce

combinations, in which the order of the items selected does not affect the
return. Combination (Combine) is categorized as a mathematical function.

Syntax

Permut(Number, NumberChosen)

Where:

Number is the number of items in a set.

NumberChosen is the number of items selected for permutation.

Expression

In the expression that follows, Number = n; NumberChosen = k.

Usage Notes

If an argument is not an integer, it is truncated.

This function returns an error value if:

l Either argument is nonnumeric

l Number < 0

l NumberChosen < 0

l Number < NumberChosen

PoissonDistribution
Returns the Poisson distribution of a random variable. This function predicts
the number of identified events to take place over a specified period. For
example, it can predict the number of cars to arrive at a toll plaza in a one-
minute interval.

Syntax

Copyright © 2023 All Rights Reserved 480


Fu n ct io n s Refer en ce

PoissonDistribution <Cumulative> (x, lambda)

Where:

x is the number of events in the prediction.

lambda is the expected numeric value of the expression.

Cumulative is a logical value that determines the form of the probability


distribution returned:

l If Cumulative = 0 (default), the function returns the probability that the


number of random events will be between 0 and x.

l If Cumulative = 1, the function returns the probability that the number of


random events will be exactly x.

Expression

For type = 1:

For type = 0:

Usage Notes

If x is not an integer, it is truncated.

The following conditions are invalid:

l x or lambda is nonnumeric

l x < 0

l lambda £ 0

Copyright © 2023 All Rights Reserved 481


Fu n ct io n s Refer en ce

RSquare (Square of Pearson Product Moment Correlation


Coefficient)
Returns the square of the Pearson product moment correlation coefficient
for a set of values. RSquare gives the proportion of the variance in y that is
attributable to the variance in x.

Syntax

RSquare <FactID> (Argument1, Argument2)

Where:

Argument1 is a list of data-point coordinates.

Argument2 is a list of data point coordinates.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Usage Notes

The following conditions are invalid:

l Argument1 and Argument2 have a different number of values.

l Either Argument1 or Argument2 contains one or more NULL values.

Skew
Returns the skewness of a data set in a given list of values. Skewness is the
degree of asymmetry of a distribution in relation to its mean. A positive
skewness indicates asymmetry biased towards positive values, while a
negative skewness indicates the opposite.

Syntax

Skew <FactID> (Argument)

Where:

Argument is a fact or metric representing a list of values.

Copyright © 2023 All Rights Reserved 482


Fu n ct io n s Refer en ce

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

In the expression that follows, s is the sample standard deviation.

Slope (of a Linear Regression)


Returns the slope of a linear regression line. In a regression line passing
through a set of data points in data sets Argument1 and Argument2, the
slope is the vertical distance divided by the horizontal distance between any
two points on the line. This ratio is also known as the rate of change along
the line.

Syntax

Slope <FactID> (Argument1, Argument2)

Where:

Argument1 is a fact or metric containing numerically dependent (y) data


points.

Argument2 is a fact or metric containing numerically independent (x) data


points.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Expression

Copyright © 2023 All Rights Reserved 483


Fu n ct io n s Refer en ce

Usage Notes

The following conditions are invalid:

l Either Argument1 or Argument2 contains NULL values.

l Argument1 and Argument2 have a different number of values.

Example

See Hypothesis Testing Example, page 83 for an example using the Slope
function.

Standardize
Returns a normalized value from a distribution characterized by a mean and
standard deviation.

Syntax

Standardize(x, Mean, Stdev)

Where:

x is the value you want to normalize.

Mean is the arithmetic mean of the distribution.

Stdev is the standard deviation of the distribution.

Expression

Usage Notes

The following is an invalid condition: Stdev £ 0

Copyright © 2023 All Rights Reserved 484


Fu n ct io n s Refer en ce

StandardNormalDistribution (Standard Normal Cumulative


Distribution)
Returns the cumulative distribution of a standard normal variable. The mean
is 0 and the standard deviation is 1. This function can be used in lieu of a
table of standard normal curve areas.

Syntax

StandardNormalDistribution (Argument)

Where:

Argument is a metric representing a list of numbers.

Expression

Usage Notes

This function results in an invalid value if Argument is nonnumeric.

SteYX (Standard Error of Estimates)


Returns the standard error of estimates in linear regression with two
variables (for example, Y = Intercept + Slope * X).

Syntax

SteYX([Y], [X])

Where:

Y is an array or range of dependent data points.

X is an array or range of independent data points.

Expression

Copyright © 2023 All Rights Reserved 485


Fu n ct io n s Refer en ce

Usage Notes

If an argument value contains text, logical values, or empty cells, those


values are ignored; however, cells with the value zero are included.

It is an invalid condition for Y and X to be empty or have a different number


of data points.

TDistribution
Returns the right-tailed distribution of a random variable. This function can
be used in lieu of a table of critical values to test hypotheses on small
sample sets.

Syntax

TDistribution(x, df)

Where:

x is the numeric value at which the distribution is evaluated.

df is a value that indicates the degrees of freedom of the distribution.

Expression

Where:

X is a random value that follows the t-distribution.

Usage Notes

If df is not an integer, it is truncated.

The following conditions are invalid:

Copyright © 2023 All Rights Reserved 486


Fu n ct io n s Refer en ce

l Either x or df is nonnumeric

l df < 1

Trend
The Trend function uses data recorded for certain time intervals to calculate
and display the expected value of data for an unknown time period. This is
most commonly used to predict future metric values based on historical
data. For example, based on revenue data for three years, you want to
predict what your Revenue will be for the coming year.

This function uses a linear equation to predict future values. Therefore, it is


best suited to predict values that increase or decrease in a linear trend. For
example, if your profits are increasing by $10,000 each year, this is a
scenario that is well suited for a prediction based on a linear equation.

For a function that predicts values in a similar way for data that is increasing
or decreasing exponentially, see GrowthV (Growth, Vector Input), page 459.

Syntax

Trend <FactID>(KnownData1,...,KnownDataN, FutureTimeOffset)

Where:

KnownData1,...,KnownDataN are separate scalar values that provide the


data to use to predict a future value for. While you can use Trend to enter
these values manually, it is more common to use TrendV which can use a
metric to enter a list of values, as described in TrendV (Trend, Vector Input),
page 488.

FutureTimeOffset is the point in time after the final time interval


available for which to predict the data. This is commonly defined as an
integer. For example, to predict values for the year 2009 when the last
available data you have is for 2007, you would enter the value of 2 for
FutureTimeOffset.

Copyright © 2023 All Rights Reserved 487


Fu n ct io n s Refer en ce

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

Example

As described in the syntax requirements, you can use Trend to enter values
manually. However, it is more common to use TrendV to use metrics and
attributes to enter this information, as described in TrendV (Trend, Vector
Input), page 488.

TrendV (Trend, Vector Input)


The TrendV function uses data recorded for certain time intervals to
calculate and display the expected value of data for an unknown time period.
This is most commonly used to predict future metric values based on
historical data. For example, based on revenue data for three years, you
want to predict what your Revenue will be for the coming year.

You can use TrendV to predict values for any point in time, including dates
that have known data. However, this type of function is meant for predicting
future, unknown values.

This function uses a linear equation to predict future values. Therefore, it is


best suited to predict values that increase or decrease in a linear trend. For
example, if your profits are increasing by $10,000 each year, this is a
scenario that is well suited for a prediction based on a linear equation.

For a function that predicts values in a similar way for data that is increasing
or decreasing exponentially, see GrowthV (Growth, Vector Input), page 459.

Syntax

TrendV <FactID, SortBy>(KnownData, FutureTimeOffset)

Where:

KnownData is an object representing a list of values. This list of values is


the known data to use to predict a future value for. KnownData is commonly
used for metrics that represent data such as revenue, profit, and so on.

Copyright © 2023 All Rights Reserved 488


Fu n ct io n s Refer en ce

FutureTimeOffset is the point in time after the final time interval


available for which to predict the data. This is commonly defined as an
integer. For example, to predict values for the year 2009 when the last
available data you have is for 2007, you would enter the value of 2 for
FutureTimeOffset.

The TrendV function assumes that data is available for sequential time
intervals with no missing data. If your data meets these requirements, this
allows you to use a single expression to use on reports with varying time
intervals such as year, month, quarter, and so on. This is an advantage of
TrendV in relation to ForecastV, which requires you to specify a time
interval such as year for each expression. For an example, see the examples
described below.

FactID is a parameter that forces a calculation to take place on a fact table


that contains the selected fact.

SortBy is a parameter that defines the order of calculation. For more


information, see BreakBy and SortBy Parameters, page 27.

Example

The TrendV function is useful to display predicted future values of a metric


as a subtotal of the metric on a report.

For example, in the MicroStrategy Tutorial project a new subtotal named


2008 Trend can be created with the following definition:

TrendV(x, 1)

Since this is in a subtotal, the x is a placeholder for a metric. When a


subtotal is applied to a metric on a report, the placeholder inputs that
metric’s values.

Also, 1 is used as the offset in the time interval to predict data for the first
time interval that is not known.

After making the new custom subtotal available for the Revenue metric (see
the Advanced Reporting Guide for steps to make custom subtotals available

Copyright © 2023 All Rights Reserved 489


Fu n ct io n s Refer en ce

for metrics) a report with the attribute Year and the metric Revenue is
created. When the 2008 Trend is displayed on the report, it displays the
predicted value for 2008 Revenue, as shown below:

This value is the same value predicted in the example using ForecastV, as
described in ForecastV (Forecast, Vector Input), page 453. The advantage
of using TrendV is that since you do not have to define the attribute or other
object that defines the time interval, you can switch the time interval used by
modifying the report. For example, the report can be modified to display
Quarter instead of Year, which allows the 2008 Trend subtotal to predict the
revenue for the first quarter of 2008. This is shown in the report below.

The type of subtotal shown above could also be created using ForecastV,
but it would require you to create a separate subtotal that used the Quarter
attribute to define the time intervals.

VarTest (Variance Test)


Returns the P-value of a test that tests the variance of the data against a
particular value.

Copyright © 2023 All Rights Reserved 490


Fu n ct io n s Refer en ce

Decision Reality: H 0 is Reality: H 1 is


correct correct

Accept H 0 No problem Type 1 error

Reject H 0 Type 2 error No problem

Definition

P-value is basically a probability of making a Type 2 error.

VarTest returns the P-value for the hypothesis test in the following form:

l H0:

l H1:

Syntax

VarTest <Hypothesis Type> (Argument, Hypothesis Variance)

Where:
Copyright © 2023 All Rights Reserved 491
Fu n ct io n s Refer en ce

Hypothesis Type is the parameter to set whether you are testing the
probability of the value being equal (0), less than (-1), greater than (1), or
not equal to (2) the sigma or variance.

Argument is a fact or metric representing the values you are testing.

HypothesisVariance is the variance you are testing.

Example

VarTest(M1, 1000) = 1000

For a set of values (M1), what is the probability that the variance of the value
will be equal to 1000? Note that M1 needs to have a defined dimensionality.

Usage Notes

For each variance test function, two tests are performed. The first tests the
probability of the value being equal (0), and the second tests the probability
of the value being less than (-1), greater than (1), or not equal to (2) the
sigma or variance. A parameter must be specified for the second test.

WeibullDistribution
Returns either the cumulative distribution or the probability density of a
random variable. Used in reliability analysis, such as the calculation of the
mean time to failure for a given device.

Syntax

WeibullDistribution <Cumulative> (x, Alpha, Beta)

Where:

x is the numeric value at which the distribution is evaluated.

Alpha is a distribution parameter.

Beta is a distribution parameter.

Cumulative is a logical value that determines the form of the function:

Copyright © 2023 All Rights Reserved 492


Fu n ct io n s Refer en ce

l If Cumulative = 0 (default), it returns the cumulative distribution.

l If Cumulative = 1, it returns the probability density.

Expression

For the Weibull cumulative distribution:

For the Weibull probability density:

When alpha = 1, the Weibull exponential return is

Usage Notes

The following conditions are invalid:

l alpha or beta is nonnumeric

l x<0

l alpha < 0

l beta < 0

Copyright © 2023 All Rights Reserved 493


Fu n ct io n s Refer en ce

M ICRO STRATEGY AN D
D ATABASE SUPPORT FOR
FUN CTION S

Copyright © 2023 All Rights Reserved 494


Fu n ct io n s Refer en ce

The functions provided with MicroStrategy can be evaluated by the


MicroStrategy Analytical Engine or passed to the database for processing.
The sections and tables in this appendix list MicroStrategy Analytical Engine
and database support for MicroStrategy functions. Reviewing this support
allows you to determine whether a MicroStrategy function can be supported
for your MicroStrategy environment.

l Analytical Engine Support for Functions, page 495

l Databases That a Function Can Be Evaluated On, page 500

For additional information on how functions are processed, see Types of


Function Processing, page 60.

Analytical Engine Support for Functions


The functions listed in the following table are supported by the
MicroStrategy Analytical Engine. This allows metrics to be evaluated by
MicroStrategy in cases where functions cannot be evaluated by a database.
It also allows metrics to support smart metric functionality (see the
Advanced Reporting Help).

Functions supported by the MicroStrategy


Function type
Analytical Engine

• Add

• Average

• Avg

• Count
Basic functions
• First

• GeoMean

• Greatest

• Last

Copyright © 2023 All Rights Reserved 495


Fu n ct io n s Refer en ce

Functions supported by the MicroStrategy


Function type
Analytical Engine

• Least

• Max

• Median

• Min

• Mode

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

All date and time functions are supported by the


Date and time functions
MicroStrategy Analytical Engine

• Banding

• BandingC

Internal functions • BandingP

• Case

• CaseV

• IsNotNull

• IsNull

Null and Zero functions • NullToEmpty

• NullToZero

• ZeroToNull

OLAP functions • ExpWghMovingAvg

Copyright © 2023 All Rights Reserved 496


Fu n ct io n s Refer en ce

Functions supported by the MicroStrategy


Function type
Analytical Engine

• ExpWghRunningAvg

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingDifference

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Copyright © 2023 All Rights Reserved 497


Fu n ct io n s Refer en ce

Functions supported by the MicroStrategy


Function type
Analytical Engine

• NTile

• NTileSize

• NTileValue
Rank and NTile functions
• NTileValueSize

• Percentile

• Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• All Arithmetic functions are supported by the


Arithmetic operators
MicroStrategy Analytical Engine

• <

• <=
Comparison operators
• <>

• =

Copyright © 2023 All Rights Reserved 498


Fu n ct io n s Refer en ce

Functions supported by the MicroStrategy


Function type
Analytical Engine

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Copyright © 2023 All Rights Reserved 499


Fu n ct io n s Refer en ce

Functions supported by the MicroStrategy


Function type
Analytical Engine

All data mining functions are supported by the


Data mining functions
MicroStrategy Analytical Engine.

All financial functions are supported by the


Financial functions
MicroStrategy Analytical Engine.

All mathematical functions are supported by the


Mathematical functions
MicroStrategy Analytical Engine.

All statistical functions are supported by the


Statistical functions
MicroStrategy Analytical Engine.

Databases That a Function Can Be Evaluated On


The tables below list the function support for each database that is certified
for use with MicroStrategy. If a function is listed for a database, the function
can be evaluated within that database. If a function cannot be evaluated
within a database, the function may be able to be supported by the
MicroStrategy Analytical Engine (see Analytical Engine Support for
Functions, page 495).

Except where explicitly stated, only databases that are certified to work with
MicroStrategy 10 are listed below. For information on the latest certification
and support for databases, see Platform Certifications.

Actian Vectorwise
The tables listed below describe the MicroStrategy function support for
Actian Vectorwise databases:

l Actian Vectorwise 2.5, page 501

l Actian Vectorwise 3.0, page 506

Copyright © 2023 All Rights Reserved 500


Fu n ct io n s Refer en ce

Actian Vectorwise 2.5

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime
Date and time functions
• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Copyright © 2023 All Rights Reserved 501


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding
Internal functions
• BandingC

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • OLAPRank

Rank and NTile functions • Rank

• Concat
String functions
• ConcatBlank

Copyright © 2023 All Rights Reserved 502


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 503


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Acosh

• Asin

Copyright © 2023 All Rights Reserved 504


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• RandBetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

Copyright © 2023 All Rights Reserved 505


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Actian Vectorwise 3.0

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

Basic functions • Least

• Max

• Min

• Multiply

• Product

• Stdev

• StdevP

Copyright © 2023 All Rights Reserved 506


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour
Date and time functions
• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

Copyright © 2023 All Rights Reserved 507


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearStartDate

• Banding
Internal functions
• BandingC

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

Arithmetic operators • x

• +

Copyright © 2023 All Rights Reserved 508


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

Comparison operators for rank • *=

• *>=

• *Between

Copyright © 2023 All Rights Reserved 509


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling
Mathematical functions
• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

Copyright © 2023 All Rights Reserved 510


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• RandBetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Aster Database
The tables listed below describe the MicroStrategy function support for Aster
Databases:

l Aster Database 4.6.x, page 512

l Databases That a Function Can Be Evaluated On, page 500

Copyright © 2023 All Rights Reserved 511


Fu n ct io n s Refer en ce

l Aster Database 5.1.x, page 522

Aster Database 4.6.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

Basic functions • Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

Date and time functions • CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

Copyright © 2023 All Rights Reserved 512


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead
OLAP functions
• MovingAvg

• MovingCount

Copyright © 2023 All Rights Reserved 513


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingMax

• MovingMin

• MovingSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• InitCap

• LeftStr

• Length

• Lower

• LTrim
String functions
• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x
Arithmetic operators
• +

• /

Copyright © 2023 All Rights Reserved 514


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

Copyright © 2023 All Rights Reserved 515


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

Mathematical functions • Cos

• Degrees

• Exp

• Floor

• Int

• Ln

• Log

• Log10

• Mod

• Power

Copyright © 2023 All Rights Reserved 516


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Aster Database 5.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest
Basic functions
• Least

• Max

• Min

• Multiply

• Stdev

• StdevP

Copyright © 2023 All Rights Reserved 517


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour
Date and time functions
• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

Copyright © 2023 All Rights Reserved 518


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearStartDate

Internal functions None

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin
OLAP functions
• MovingSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• InitCap

• LeftStr
String functions
• Length

• Lower

• LTrim

Copyright © 2023 All Rights Reserved 519


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With
Comparison operators
• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

Copyright © 2023 All Rights Reserved 520


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

Mathematical functions • Asinh

• Atan

• Atan2

• Atanh

• Ceiling

Copyright © 2023 All Rights Reserved 521


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Cos

• Degrees

• Exp

• Floor

• Int

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Aster Database 5.1.x

Function type Functions that can be evaluated on the database

• Add
Basic functions
• Average

Copyright © 2023 All Rights Reserved 522


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date
Date and time functions
• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 523


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions None

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

OLAP functions • MovingMax

• MovingMin

• MovingSum

• RunningAvg

• RunningCount

Copyright © 2023 All Rights Reserved 524


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• InitCap

• LeftStr

• Length

• Lower

• LTrim
String functions
• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=
Comparison operators
• <>

• =

Copyright © 2023 All Rights Reserved 525


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Copyright © 2023 All Rights Reserved 526


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp
Mathematical functions
• Floor

• Int

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

Copyright © 2023 All Rights Reserved 527


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sqrt

• Tan

• Trunc

Statistical functions None

Calpont InfiniDB
The tables listed below describe the MicroStrategy function support for
Calpont InfiniDB databases:

l Calpont InfiniDB 2.2.x, page 528

l Calpont InfiniDB 3.x, page 533

Calpont InfiniDB 2.2.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

Basic functions • Greatest

• Least

• Max

• Min

• Multiply

• Product

Copyright © 2023 All Rights Reserved 528


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween
Date and time functions
• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

Copyright © 2023 All Rights Reserved 529


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Year

• YearEndDate

• YearStartDate

• Banding
Internal functions
• BandingC

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• ConcatBlank

• Concat

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

Arithmetic operators • -

Copyright © 2023 All Rights Reserved 530


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• x

• +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

Comparison operators for rank • *<>

• *=

Copyright © 2023 All Rights Reserved 531


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh
Mathematical functions
• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Ln

• Log

Copyright © 2023 All Rights Reserved 532


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Calpont InfiniDB 3.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count
Basic functions
• GeoMean

• Greatest

• Least

• Max

Copyright © 2023 All Rights Reserved 533


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

Copyright © 2023 All Rights Reserved 534


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding
Internal functions
• BandingC

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• ConcatBlank

• Concat

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

Copyright © 2023 All Rights Reserved 535


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 536


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp

• Floor

Copyright © 2023 All Rights Reserved 537


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Int

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

EXASolution
The tables listed below describe the MicroStrategy function support for
EXASolution databases:

l EXASolution 4.x, page 539

Copyright © 2023 All Rights Reserved 538


Fu n ct io n s Refer en ce

EXASolution 4.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Median

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime
Date and time functions
• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Copyright © 2023 All Rights Reserved 539


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

OLAP functions • MovingAvg

• MovingCount

• MovingMax

Copyright © 2023 All Rights Reserved 540


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingMin

• MovingSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

Comparison operators • <

Copyright © 2023 All Rights Reserved 541


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND
Logical operators
• IF

Copyright © 2023 All Rights Reserved 542


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

Mathematical functions • Degrees

• Exp

• Floor

• Int

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

Copyright © 2023 All Rights Reserved 543


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Greenplum
The tables listed below describe the MicroStrategy function support for
Greenplum databases:

l Greenplum 4.x, page 544

Greenplum 4.x

Function type Functions that can be evaluated on the database

• Add

Basic functions • Average

• Avg

Copyright © 2023 All Rights Reserved 544


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Count

• GeoMean

• Greatest

• Least

• Max

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date
Date and time functions
• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 545


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap
String functions
• LeftStr

• Length

• Lower

Copyright © 2023 All Rights Reserved 546


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

Comparison operators • Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

Copyright © 2023 All Rights Reserved 547


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin
Mathematical functions
• Asinh

• Atan

• Atan2

• Atanh

Copyright © 2023 All Rights Reserved 548


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Copyright © 2023 All Rights Reserved 549


Fu n ct io n s Refer en ce

Hadoop Hive
The tables listed below describe the MicroStrategy function support for
Hadoop Hive databases:

l Hadoop Hive, page 550

Hadoop Hive

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• First

• GeoMean

• Greatest

• Last

Basic functions • Least

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays
Date and time functions
• CurrentDate

Copyright © 2023 All Rights Reserved 550


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DaysBetween

• Hour

• Minute

• Month

• Second

• Week

• Year

Internal functions None

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• LeftStr

• Length

String functions • Lower

• LTrim

• Position

• RightStr

Copyright © 2023 All Rights Reserved 551


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between
Comparison operators
• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

Copyright © 2023 All Rights Reserved 552


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 553


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Covariance
Statistical functions
• Standardize

HP Vertica
The tables listed below describe the MicroStrategy function support for HP
Vertica databases:

l HP Vertica 5.1 , page 555

l HP Vertica 6.x , page 560

Copyright © 2023 All Rights Reserved 554


Fu n ct io n s Refer en ce

HP Vertica 5.1

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime
Date and time functions
• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Copyright © 2023 All Rights Reserved 555


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

Internal functions None

• NullToZero
Null and Zero functions
• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg
OLAP functions
• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

Copyright © 2023 All Rights Reserved 556


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

Copyright © 2023 All Rights Reserved 557


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 558


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp

• Ln

Copyright © 2023 All Rights Reserved 559


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions • Standardize

HP Vertica 6.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

Basic functions • Count

• GeoMean

• Max

• Min

Copyright © 2023 All Rights Reserved 560


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear
Date and time functions
• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

Copyright © 2023 All Rights Reserved 561


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Second

• Year

• YearEndDate

• YearStartDate

Internal functions None

• NullToZero
Null and Zero functions
• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev
OLAP functions
• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

Copyright © 2023 All Rights Reserved 562


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

Comparison operators • <

Copyright © 2023 All Rights Reserved 563


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND
Logical operators
• IF

Copyright © 2023 All Rights Reserved 564


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

Mathematical functions • Degrees

• Exp

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

Copyright © 2023 All Rights Reserved 565


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions • Standardize

IBM DB2
The tables listed below describe the MicroStrategy function support for IBM
DB2 databases:

l DB2 V9.5 for Linux, UNIX, and Windows, page 566

l DB2 V9.7 for Linux, UNIX, and Windows, page 573

l DB2 V10.1 for Linux, UNIX, and Windows, page 579

l DB2 V10.5 for Linux, UNIX, and Windows, page 585

l DB2 for i 6.1, page 591

l DB2 for i 7.1, page 596

DB2 V9.5 for Linux, UNIX, and Windows

Function type Functions that can be evaluated on the database

• Add

• Average
Basic functions
• Avg

• Count

Copyright © 2023 All Rights Reserved 566


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• GeoMean

• Max

• Min

• Multiply

• Product

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek
Date and time functions
• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

Copyright © 2023 All Rights Reserved 567


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

OLAP functions • MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

Copyright © 2023 All Rights Reserved 568


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

Copyright © 2023 All Rights Reserved 569


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=
Comparison operators for rank
• *<>

Copyright © 2023 All Rights Reserved 570


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *=

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

Mathematical functions • Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

Copyright © 2023 All Rights Reserved 571


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Copyright © 2023 All Rights Reserved 572


Fu n ct io n s Refer en ce

DB2 V9.7 for Linux, UNIX, and Windows

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Min

• Multiply

• Product

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

Date and time functions • CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

Copyright © 2023 All Rights Reserved 573


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead
OLAP functions
• MovingAvg

• MovingCount

Copyright © 2023 All Rights Reserved 574


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap
String functions
• LeftStr

• Length

• Lower

Copyright © 2023 All Rights Reserved 575


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

Comparison operators • Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

Copyright © 2023 All Rights Reserved 576


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin
Mathematical functions
• Asinh

• Atan

• Atan2

• Atanh

Copyright © 2023 All Rights Reserved 577


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions • Correlation

Copyright © 2023 All Rights Reserved 578


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Covariance

• Intercept

• RSquare

• Slope

DB2 V10.1 for Linux, UNIX, and Windows

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Min

• Multiply

• Product

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths
Date and time functions
• CurrentDate

• CurrentDateTime

Copyright © 2023 All Rights Reserved 579


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

Null and Zero functions • IsNull

• NullToZero

Copyright © 2023 All Rights Reserved 580


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount
OLAP functions
• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

String functions • Concat

Copyright © 2023 All Rights Reserved 581


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =
Comparison operators
• >

• >=

• Begins With

• Between

Copyright © 2023 All Rights Reserved 582


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

Mathematical functions • Acos

• Acosh

Copyright © 2023 All Rights Reserved 583


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

Copyright © 2023 All Rights Reserved 584


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

DB2 V10.5 for Linux, UNIX, and Windows

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max
Basic functions
• Min

• Multiply

• Product

• StdevP

• Sum

• Var

Copyright © 2023 All Rights Reserved 585


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Date and time functions • MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Banding

Copyright © 2023 All Rights Reserved 586


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

OLAP functions • OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

Copyright © 2023 All Rights Reserved 587


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

Comparison operators • <=

• <>

Copyright © 2023 All Rights Reserved 588


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Copyright © 2023 All Rights Reserved 589


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

Mathematical functions • Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

Copyright © 2023 All Rights Reserved 590


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

DB2 for i 6.1

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

Basic functions • Count

• GeoMean

• Max

• Min

Copyright © 2023 All Rights Reserved 591


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear
Date and time functions
• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

Copyright © 2023 All Rights Reserved 592


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

Copyright © 2023 All Rights Reserved 593


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 594


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 595


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions None

DB2 for i 7.1

Function type Functions that can be evaluated on the database

Basic functions • Add

Copyright © 2023 All Rights Reserved 596


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Average

• Avg

• Count

• GeoMean

• Max

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date
Date and time functions
• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 597


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions • Rank

• Concat

• ConcatBlank

String functions • InitCap

• LeftStr

• Length

Copyright © 2023 All Rights Reserved 598


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=
Comparison operators
• Begins With

• Between

• Contains

• Ends With

• In

• Like

Copyright © 2023 All Rights Reserved 599


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

Mathematical functions • Asin

• Asinh

• Atan

• Atan2

Copyright © 2023 All Rights Reserved 600


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 601


Fu n ct io n s Refer en ce

IBM Informix
The tables listed below describe the MicroStrategy function support for IBM
Informix databases:

l IBM Informix IDS 11.5 and Informix Ultimate Edition 11.7, page 602

l IBM Informix Ultimate Edition 12.1, page 606

l IBM Informix XPS 8.x, page 611

IBM Informix IDS 11.5 and Informix Ultimate Edition 11.7

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• Max
Basic functions
• Min

• Multiply

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate
Date and time functions
• CurrentDateTime

• CurrentTime

• Date

Copyright © 2023 All Rights Reserved 602


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

Copyright © 2023 All Rights Reserved 603


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 604


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Asin

• Atan

Copyright © 2023 All Rights Reserved 605


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan2

• Ceiling

• Cos

• Exp

• Floor

• Int

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

IBM Informix Ultimate Edition 12.1

Function type Functions that can be evaluated on the database

• Add
Basic functions
• Average

Copyright © 2023 All Rights Reserved 606


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Avg

• Count

• Max

• Min

• Multiply

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

Copyright © 2023 All Rights Reserved 607


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• OLAPAvg
OLAP functions
• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

Rank and NTile functions None

• Concat
String functions
• ConcatBlank

Copyright © 2023 All Rights Reserved 608


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

Comparison operators • >=

• Begins With

• Between

• Contains

• Ends With

• In

Copyright © 2023 All Rights Reserved 609


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Asin
Mathematical functions
• Atan

• Atan2

• Ceiling

Copyright © 2023 All Rights Reserved 610


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Cos

• Exp

• Floor

• Int

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

IBM Informix XPS 8.x

Function type Functions that can be evaluated on the database

• Add

• Average
Basic functions
• Avg

• Count

Copyright © 2023 All Rights Reserved 611


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Max

• Min

• Multiply

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

Date and time functions • DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

Copyright © 2023 All Rights Reserved 612


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• RightStr

• RTrim

• SubStr

• Trim

• -
Arithmetic operators
• x

Copyright © 2023 All Rights Reserved 613


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>
Comparison operators for rank
• *=

• *>=

Copyright © 2023 All Rights Reserved 614


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Asin

• Atan

• Atan2

• Ceiling

• Cos

• Exp

Mathematical functions • Floor

• Int

• Int2

• Ln

• Log10

• Mod

• Power

• Round

• Round2

Copyright © 2023 All Rights Reserved 615


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

IBM Netezza
The tables listed below describe the MicroStrategy function support for IBM
Netezza databases:

l IBM Netezza 5.0.x, page 616

l IBM Netezza 6.0.x, page 623

l IBM Netezza 7.0.x, page 629

IBM Netezza 5.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

Basic functions • GeoMean

• Max

• Min

• Multiply

• Product

Copyright © 2023 All Rights Reserved 616


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween
Date and time functions
• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

Copyright © 2023 All Rights Reserved 617


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

OLAP functions • MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

Copyright © 2023 All Rights Reserved 618


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

Arithmetic operators • x

• +

Copyright © 2023 All Rights Reserved 619


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

Comparison operators for rank • *=

• *>=

• *Between

Copyright © 2023 All Rights Reserved 620


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling
Mathematical functions
• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

Copyright © 2023 All Rights Reserved 621


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

Statistical functions • Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Copyright © 2023 All Rights Reserved 622


Fu n ct io n s Refer en ce

IBM Netezza 6.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime
Date and time functions
• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Copyright © 2023 All Rights Reserved 623


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

OLAP functions • LastInRange

• Lead

• MovingAvg

Copyright © 2023 All Rights Reserved 624


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

String functions • InitCap

• LeftStr

• Length

Copyright © 2023 All Rights Reserved 625


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

Comparison operators • Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

Copyright © 2023 All Rights Reserved 626


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin
Mathematical functions
• Asinh

• Atan

• Atan2

• Atanh

Copyright © 2023 All Rights Reserved 627


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions • Correlation

Copyright © 2023 All Rights Reserved 628


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis

• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

IBM Netezza 7.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean
Basic functions
• Max

• Min

• Multiply

• Product

• Stdev

Copyright © 2023 All Rights Reserved 629


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Date and time functions • Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

Copyright © 2023 All Rights Reserved 630


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin
OLAP functions
• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

Copyright © 2023 All Rights Reserved 631


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x
Arithmetic operators
• +

• /

Copyright © 2023 All Rights Reserved 632


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

Copyright © 2023 All Rights Reserved 633


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

Mathematical functions • Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

Copyright © 2023 All Rights Reserved 634


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Copyright © 2023 All Rights Reserved 635


Fu n ct io n s Refer en ce

IBM Red Brick


The tables listed below describe the MicroStrategy function support for IBM
Red Brick databases:

l IBM Red Brick 6.3, page 636

IBM Red Brick 6.3

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count
Basic functions
• Max

• Min

• Multiply

• Sum

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 636


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg
OLAP functions
• MovingCount

• MovingMax

• MovingMin

Copyright © 2023 All Rights Reserved 637


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

Copyright © 2023 All Rights Reserved 638


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=
Comparison operators for rank
• *<>

Copyright © 2023 All Rights Reserved 639


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *=

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Ceiling

• Exp

• Floor

• Int

• Int2
Mathematical functions
• Ln

• Mod

• Quotient

• Round

• Round2

• Sqrt

Statistical functions None

Copyright © 2023 All Rights Reserved 640


Fu n ct io n s Refer en ce

Infobright
The tables listed below describe the MicroStrategy function support for
Infobright databases:

l Infobright 4.0.x, page 641

Infobright 4.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

Date and time functions • AddMonths

• CurrentDate

Copyright © 2023 All Rights Reserved 641


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

Null and Zero functions • IsNull

• NullToZero

Copyright © 2023 All Rights Reserved 642


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=
Comparison operators
• <>

• =

Copyright © 2023 All Rights Reserved 643


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Copyright © 2023 All Rights Reserved 644


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees
Mathematical functions
• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

Copyright © 2023 All Rights Reserved 645


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions None

Kognitio
The tables listed below describe the MicroStrategy function support for
Kognitio databases:

l Kognitio WX2 7.x, page 646

Kognitio WX2 7.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

Basic functions • Count

• First

• GeoMean

• Greatest

Copyright © 2023 All Rights Reserved 646


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Last

• Least

• Max

• Min

• Multiply

• StdevP

• Sum

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

Copyright © 2023 All Rights Reserved 647


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions None

• NullToZero
Null and Zero functions
• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdevP

• MovingSum

OLAP functions • OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

Copyright © 2023 All Rights Reserved 648


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningMin

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

Comparison operators • <>

• =

• >

Copyright © 2023 All Rights Reserved 649


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

Copyright © 2023 All Rights Reserved 650


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Mathematical functions • Floor

• Int

• Ln

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

Copyright © 2023 All Rights Reserved 651


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Tan

• Tanh

• Trunc

Statistical functions • Standardize

Maria DB
The tables listed below describe the MicroStrategy function support for
Maria DB databases:

l Maria DB 5.5.x, page 652

Maria DB 5.5.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest
Basic functions
• Least

• Max

• Min

• Multiply

• Product

• Stdev

Copyright © 2023 All Rights Reserved 652


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Date and time functions • Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

Copyright © 2023 All Rights Reserved 653


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -
Arithmetic operators
• x

Copyright © 2023 All Rights Reserved 654


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>
Comparison operators for rank
• *=

• *>=

Copyright © 2023 All Rights Reserved 655


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

Mathematical functions • Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

Copyright © 2023 All Rights Reserved 656


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Microsoft Access
The tables listed below describe the MicroStrategy function support for
Microsoft Access databases:

l Microsoft Access 2000, 2002, or 2003, page 657

l Microsoft Access 2007, page 661

Microsoft Access 2000, 2002, or 2003


Microsoft Access 2000, 2002, or 2003 are only supported for demonstration
purposes.

Copyright © 2023 All Rights Reserved 657


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count
Basic functions
• Max

• Min

• Multiply

• Sum

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

Copyright © 2023 All Rights Reserved 658


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• Position

• RightStr

• SubStr

• Trim

• Upper

Copyright © 2023 All Rights Reserved 659


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=
Comparison operators for rank
• *<>

Copyright © 2023 All Rights Reserved 660


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *=

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Floor

• Int

• Int2
Mathematical functions
• Ln

• Mod

• Quotient

Statistical functions None

Microsoft Access 2007


Microsoft Access 2007 is only supported for demonstration purposes.

Function type Functions that can be evaluated on the database

• Add
Basic functions
• Average

Copyright © 2023 All Rights Reserved 661


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Avg

• Count

• GeoMean

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth
Date and time functions
• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Millisecond

• Minute

• Month

Copyright © 2023 All Rights Reserved 662


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr
String functions
• Length

• Lower

• LTrim

• Position

Copyright © 2023 All Rights Reserved 663


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

Comparison operators • Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

Copyright © 2023 All Rights Reserved 664


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Cos

• Exp

• Floor

• Int
Mathematical functions
• Int2

• Ln

• Log

• Log10

• Mod

Copyright © 2023 All Rights Reserved 665


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

Statistical functions None

Microsoft SQL Server


The tables listed below describe the MicroStrategy function support for
Microsoft SQL Server databases:

l Microsoft SQL Server 2005, page 666

l Microsoft SQL Server 2008, page 672

l Microsoft SQL Server 2008 R2 Parallel Data Warehouse, page 677

l Microsoft SQL Server 2012, page 682

l Microsoft SQL Server 2012 Parallel Data Warehouse, page 687

l Microsoft SQL Database, page 692

Microsoft SQL Server 2005

Function type Functions that can be evaluated on the database

• Add
Basic functions
• Average

Copyright © 2023 All Rights Reserved 666


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Avg

• Count

• GeoMean

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth
Date and time functions
• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

Copyright © 2023 All Rights Reserved 667


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

String functions • LeftStr

• Length

• Lower

• LTrim

Copyright © 2023 All Rights Reserved 668


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With
Comparison operators
• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

Copyright © 2023 All Rights Reserved 669


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

Mathematical functions • Asinh

• Atan

• Atan2

• Atanh

• Ceiling

Copyright © 2023 All Rights Reserved 670


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 671


Fu n ct io n s Refer en ce

Microsoft SQL Server 2008

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 672


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank
String functions
• InitCap

• LeftStr

Copyright © 2023 All Rights Reserved 673


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

Comparison operators • >=

• Begins With

• Between

• Contains

• Ends With

• In

Copyright © 2023 All Rights Reserved 674


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh
Mathematical functions
• Asin

• Asinh

• Atan

Copyright © 2023 All Rights Reserved 675


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 676


Fu n ct io n s Refer en ce

Microsoft SQL Server 2008 R2 Parallel Data Warehouse

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 677


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

OLAP functions • Lead

• OLAPRank

Rank and NTile functions • Rank

• Concat
String functions
• ConcatBlank

Copyright © 2023 All Rights Reserved 678


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 679


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acosh
Mathematical functions
• Asin

• Asinh

Copyright © 2023 All Rights Reserved 680


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan

• Atanh

• Ceiling

• Cos

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 681


Fu n ct io n s Refer en ce

Microsoft SQL Server 2012

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 682


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• LastInRange

• Lead
OLAP functions
• MovingAvg

• MovingCount

• MovingMax

Copyright © 2023 All Rights Reserved 683


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

String functions • LeftStr

• Length

• Lower

• LTrim

Copyright © 2023 All Rights Reserved 684


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

Comparison operators • Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

Copyright © 2023 All Rights Reserved 685


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh
Mathematical functions
• Atan

• Atanh

• Atan2

• Ceiling

• Cos

Copyright © 2023 All Rights Reserved 686


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Microsoft SQL Server 2012 Parallel Data Warehouse

Function type Functions that can be evaluated on the database

• Add

• Average
Basic functions
• Avg

• Count

Copyright © 2023 All Rights Reserved 687


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• GeoMean

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek
Date and time functions
• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

Copyright © 2023 All Rights Reserved 688


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

OLAP functions • Lead

• OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

String functions • LeftStr

• Length

• Lower

• LTrim

Copyright © 2023 All Rights Reserved 689


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With
Comparison operators
• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

Copyright © 2023 All Rights Reserved 690


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acosh

• Asin

• Asinh

Mathematical functions • Atan

• Atanh

• Ceiling

• Cos

• Exp

Copyright © 2023 All Rights Reserved 691


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Microsoft SQL Database

Function type Functions that can be evaluated on the database

• Add

• Average

Basic functions • Avg

• Count

• GeoMean

Copyright © 2023 All Rights Reserved 692


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Max

• Min

• Multiply

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

Copyright © 2023 All Rights Reserved 693


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length
String functions
• Lower

• LTrim

• Position

• RightStr

• RTrim

Copyright © 2023 All Rights Reserved 694


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

Comparison operators • Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

Copyright © 2023 All Rights Reserved 695


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan
Mathematical functions
• Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 696


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

MySQL
The tables listed below describe the MicroStrategy function support for
MySQL databases:

l MySQL 5.x, page 698

Copyright © 2023 All Rights Reserved 697


Fu n ct io n s Refer en ce

MySQL 5.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime
Date and time functions
• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Copyright © 2023 All Rights Reserved 698


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat
String functions
• ConcatBlank

Copyright © 2023 All Rights Reserved 699


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 700


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Acosh

• Asin

Copyright © 2023 All Rights Reserved 701


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 702


Fu n ct io n s Refer en ce

Oracle
The tables listed below describe the MicroStrategy function support for
Oracle databases:

l Oracle 10g, page 703

l Oracle 10gR2, page 710

l Oracle 11g, page 716

l Oracle 11g R2, page 723

l Oracle 12c, page 730

Oracle 10g

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• First

• GeoMean

• Greatest
Basic functions
• Last

• Least

• Max

• Median

• Min

• Multiply

• Product

Copyright © 2023 All Rights Reserved 703


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween
Date and time functions
• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

Copyright © 2023 All Rights Reserved 704


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin
OLAP functions
• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

Copyright © 2023 All Rights Reserved 705


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x
Arithmetic operators
• +

• /

Copyright © 2023 All Rights Reserved 706


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

Copyright © 2023 All Rights Reserved 707


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

Mathematical functions • Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

Copyright © 2023 All Rights Reserved 708


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Copyright © 2023 All Rights Reserved 709


Fu n ct io n s Refer en ce

Oracle 10gR2

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• First

• GeoMean

• Greatest

• Last

• Least

Basic functions • Max

• Median

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

Date and time functions • CurrentDate

• CurrentDateTime

• CurrentTime

Copyright © 2023 All Rights Reserved 710


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • FirstInRange

Copyright © 2023 All Rights Reserved 711


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

String functions • Concat

Copyright © 2023 All Rights Reserved 712


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 713


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Acosh

• Asin

Copyright © 2023 All Rights Reserved 714


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

Copyright © 2023 All Rights Reserved 715


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Oracle 11g

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

Basic functions • Count

• First

• GeoMean

• Greatest

Copyright © 2023 All Rights Reserved 716


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Last

• Least

• Max

• Median

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

Date and time functions • DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

Copyright © 2023 All Rights Reserved 717


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

OLAP functions • MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

Copyright © 2023 All Rights Reserved 718


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

String functions • Length

• Lower

• LTrim

• Position

• RightStr

Copyright © 2023 All Rights Reserved 719


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

Comparison operators • Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

Copyright © 2023 All Rights Reserved 720


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan
Mathematical functions
• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

Copyright © 2023 All Rights Reserved 721


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher
Statistical functions
• Intercept

• InverseFisher

• Kurtosis

Copyright © 2023 All Rights Reserved 722


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Oracle 11g R2

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• First

• GeoMean

• Greatest

Basic functions • Last

• Least

• Max

• Median

• Min

• Multiply

• Product

• Stdev

Copyright © 2023 All Rights Reserved 723


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Date and time functions • Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

Copyright © 2023 All Rights Reserved 724


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

OLAP functions • MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

Copyright © 2023 All Rights Reserved 725


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

Copyright © 2023 All Rights Reserved 726


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

Logical operators • AND

Copyright © 2023 All Rights Reserved 727


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• IF

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos
Mathematical functions
• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

Copyright © 2023 All Rights Reserved 728


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Copyright © 2023 All Rights Reserved 729


Fu n ct io n s Refer en ce

Oracle 12c

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• First

• GeoMean

• Greatest

• Last

• Least

Basic functions • Max

• Median

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

Date and time functions • CurrentDate

• CurrentDateTime

• CurrentTime

Copyright © 2023 All Rights Reserved 730


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions • FirstInRange

Copyright © 2023 All Rights Reserved 731


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingStdevP

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

String functions • Concat

Copyright © 2023 All Rights Reserved 732


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 733


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Acosh

• Asin

Copyright © 2023 All Rights Reserved 734


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

Copyright © 2023 All Rights Reserved 735


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Actian Matrix
The tables listed below describe the MicroStrategy function support for
Actian Matrix databases:

Actian Matrix was previously referred to as ParAccel.

l Actian Matrix 3.1.x, page 737

l Actian Matrix 3.5.x, page 743

l Actian Matrix 4.0.x, page 749

Copyright © 2023 All Rights Reserved 736


Fu n ct io n s Refer en ce

Actian Matrix 3.1.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

Basic functions • Max

• Min

• Multiply

• Product

• Sum

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

Date and time functions • DayOfMonth

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

Copyright © 2023 All Rights Reserved 737


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg
OLAP functions
• MovingCount

• MovingMax

• MovingMin

• MovingSum

• OLAPAvg

Copyright © 2023 All Rights Reserved 738


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -
Arithmetic operators
• x

Copyright © 2023 All Rights Reserved 739


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>
Comparison operators for rank
• *=

• *>=

Copyright © 2023 All Rights Reserved 740


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

Mathematical functions • Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Ln

• Log

Copyright © 2023 All Rights Reserved 741


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Covariance

• Fisher

• Intercept

• InverseFisher
Statistical functions
• Kurtosis

• RSquare

• Slope

• Standardize

Copyright © 2023 All Rights Reserved 742


Fu n ct io n s Refer en ce

Actian Matrix 3.5.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Sum

• Stdev

• StdevP

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime
Date and time functions
• Date

• DayOfMonth

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 743


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead
OLAP functions
• MovingAvg

• MovingCount

• MovingMax

• MovingMin

Copyright © 2023 All Rights Reserved 744


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

Copyright © 2023 All Rights Reserved 745


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=
Comparison operators for rank
• *<>

Copyright © 2023 All Rights Reserved 746


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *=

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

Mathematical functions • Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

Copyright © 2023 All Rights Reserved 747


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Tan

• Tanh

• Trunc

• Covariance

• Fisher

• Intercept

• InverseFisher
Statistical functions
• Kurtosis

• RSquare

• Slope

• Standardize

Copyright © 2023 All Rights Reserved 748


Fu n ct io n s Refer en ce

Actian Matrix 4.0.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Sum

• Stdev

• StdevP

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime
Date and time functions
• Date

• DayOfMonth

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 749


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead
OLAP functions
• MovingAvg

• MovingCount

• MovingMax

• MovingMin

Copyright © 2023 All Rights Reserved 750


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

Copyright © 2023 All Rights Reserved 751


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=
Comparison operators for rank
• *<>

Copyright © 2023 All Rights Reserved 752


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *=

• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

Mathematical functions • Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

Copyright © 2023 All Rights Reserved 753


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Tan

• Tanh

• Trunc

• Covariance

• Fisher

• Intercept

• InverseFisher
Statistical functions
• Kurtosis

• RSquare

• Slope

• Standardize

Copyright © 2023 All Rights Reserved 754


Fu n ct io n s Refer en ce

PostgreSQL
The tables listed below describe the MicroStrategy function support for
PostgreSQL databases:

l PostgreSQL 8.4, page 755

l PostgreSQL 9.x, page 760

PostgreSQL 8.4

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays
Date and time functions
• AddMonths

Copyright © 2023 All Rights Reserved 755


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull
Null and Zero functions
• IsNull

Copyright © 2023 All Rights Reserved 756


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• NullToZero

• ZeroToNull

• FirstInRange

OLAP functions • LastInRange

• OLAPRank

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

String functions • LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

Comparison operators • <

Copyright © 2023 All Rights Reserved 757


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND
Logical operators
• IF

Copyright © 2023 All Rights Reserved 758


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

Mathematical functions • Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

Copyright © 2023 All Rights Reserved 759


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

PostgreSQL 9.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count
Basic functions
• GeoMean

• Greatest

• Least

• Max

Copyright © 2023 All Rights Reserved 760


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

Date and time functions • DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

Copyright © 2023 All Rights Reserved 761


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

OLAP functions • LastInRange

• OLAPRank

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

String functions • Length

• Lower

• LTrim

• Position

• RightStr

Copyright © 2023 All Rights Reserved 762


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between
Comparison operators
• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

Copyright © 2023 All Rights Reserved 763


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

Mathematical functions • Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Degrees

Copyright © 2023 All Rights Reserved 764


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

• Correlation

• Covariance

Statistical functions • Intercept

• RSquare

• Slope

Copyright © 2023 All Rights Reserved 765


Fu n ct io n s Refer en ce

Salesforce.com
The tables listed below describe the MicroStrategy function support for
Salesforce.com data sources:

l Salesforce.com, page 766

Salesforce.com

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

Basic functions • GeoMean

• Max

• Min

• Multiply

• Sum

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth
Date and time functions
• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 766


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthsBetween

• Quarter

• Second

• Week

• Year

Internal functions • Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

String functions • Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

Copyright © 2023 All Rights Reserved 767


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 768


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atanh

• Atan2

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 769


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Randbetween

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

Statistical functions • Standardize

SAND CDBMS
The tables listed below describe the MicroStrategy function support for
SAND CDBMS databases:

l SAND CDBMS 6.1, page 771

l SAND CDBMS 7.1, page 775

Copyright © 2023 All Rights Reserved 770


Fu n ct io n s Refer en ce

SAND CDBMS 6.1

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Median

• Min

• Multiply

• Product

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 771


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap
String functions
• LeftStr

• Length

• Lower

Copyright © 2023 All Rights Reserved 772


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

Comparison operators • Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

Copyright © 2023 All Rights Reserved 773


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin
Mathematical functions
• Asinh

• Atan

• Atanh

• Ceiling

Copyright © 2023 All Rights Reserved 774


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Ln

• Log10

• Power

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Correlation

Statistical functions • Covariance

• Intercept

SAND CDBMS 7.1

Function type Functions that can be evaluated on the database

Basic functions • Add

Copyright © 2023 All Rights Reserved 775


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Average

• Avg

• Count

• GeoMean

• Max

• Median

• Min

• Multiply

• Product

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

Date and time functions • DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

Copyright © 2023 All Rights Reserved 776


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr
String functions
• Length

• Lower

• LTrim

• Position

Copyright © 2023 All Rights Reserved 777


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RightStr

• RTrim

• SubStr

• Trim

• Upper

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

Comparison operators • Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

Copyright © 2023 All Rights Reserved 778


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh
Mathematical functions
• Atan

• Atanh

• Ceiling

• Cos

• Cosh

Copyright © 2023 All Rights Reserved 779


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Degrees

• Exp

• Floor

• Int

• Ln

• Log10

• Power

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Correlation

Statistical functions • Covariance

• Intercept

SAP HANA 1.x


The tables listed below describe the MicroStrategy function support for SAP
HANA 1.x databases:

l SAP HANA 1.0 SP4 , page 781

l SAP HANA 1.0 SP5 , page 785

Copyright © 2023 All Rights Reserved 780


Fu n ct io n s Refer en ce

SAP HANA 1.0 SP4

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

Basic functions • Least

• Max

• Min

• Multiply

• Stdev

• Sum

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 781


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding
Internal functions
• BandingC

• NullToZero
Null and Zero functions
• ZeroToNull

OLAP functions None

Rank and NTile functions None

String functions None

• -

• x

Arithmetic operators • +

• /

• U-

Comparison operators • <

Copyright © 2023 All Rights Reserved 782


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• NotIn

• NotLike

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND
Logical operators
• IF

Copyright © 2023 All Rights Reserved 783


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

Mathematical functions • Cosh

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

Copyright © 2023 All Rights Reserved 784


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions None

SAP HANA 1.0 SP5

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest
Basic functions
• Least

• Max

• Min

• Multiply

• Stdev

• Sum

Copyright © 2023 All Rights Reserved 785


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Var

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Date and time functions • MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

Internal functions • Banding

Copyright © 2023 All Rights Reserved 786


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• BandingC

• NullToZero
Null and Zero functions
• ZeroToNull

• Lag

OLAP functions • Lead

• OLAPRank

Rank and NTile functions None

String functions None

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=
Comparison operators
• Begins With

• Between

• Contains

• Ends With

• In

• Like

Copyright © 2023 All Rights Reserved 787


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• NotIn

• NotLike

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

Mathematical functions • Asin

• Asinh

• Atan

• Atan2

Copyright © 2023 All Rights Reserved 788


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atanh

• Ceiling

• Cos

• Cosh

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions None

Copyright © 2023 All Rights Reserved 789


Fu n ct io n s Refer en ce

Sybase
The tables listed below describe the MicroStrategy function support for SAP
Sybase databases:

l SAP Sybase ASE 15.x, page 790

l SAP Sybase IQ 15.2, page 794

l SAP Sybase IQ 15.3, page 800

l SAP Sybase IQ 15.4, page 806

l SAP Sybase IQ 16.0, page 812

SAP Sybase ASE 15.x

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count
Basic functions
• Max

• Min

• Multiply

• Sum

• AddDays

• AddMonths

• CurrentDate
Date and time functions
• CurrentDateTime

• CurrentTime

• Date

Copyright © 2023 All Rights Reserved 790


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

OLAP functions None

Rank and NTile functions None

String functions • Concat

Copyright © 2023 All Rights Reserved 791


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 792


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Asin

• Atan

Copyright © 2023 All Rights Reserved 793


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan2

• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

Statistical functions None

SAP Sybase IQ 15.2

Function type Functions that can be evaluated on the database

Basic functions • Add

Copyright © 2023 All Rights Reserved 794


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Average

• Avg

• Count

• GeoMean

• Max

• Median

• Min

• Multiply

• Stdev

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

Date and time functions • DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

Copyright © 2023 All Rights Reserved 795


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead
OLAP functions
• MovingAvg

• MovingCount

• MovingMax

• MovingMin

Copyright © 2023 All Rights Reserved 796


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingStdev

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length
String functions
• Lower

• LTrim

• Position

• RightStr

• RTrim

Copyright © 2023 All Rights Reserved 797


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 798


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Asin

• Atan

• Atan2

• Ceiling

Mathematical functions • Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

Copyright © 2023 All Rights Reserved 799


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions • Correlation

SAP Sybase IQ 15.3

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

Basic functions • GeoMean

• Max

• Median

• Min

• Multiply

Copyright © 2023 All Rights Reserved 800


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Stdev

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

Date and time functions • Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

Copyright © 2023 All Rights Reserved 801


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin
OLAP functions
• MovingStdev

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

Copyright © 2023 All Rights Reserved 802


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

Comparison operators • <

Copyright © 2023 All Rights Reserved 803


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND
Logical operators
• IF

Copyright © 2023 All Rights Reserved 804


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Asin

• Atan

• Atan2

• Ceiling

• Cos

• Degrees

• Exp

• Floor

Mathematical functions • Int

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

Copyright © 2023 All Rights Reserved 805


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sqrt

• Tan

• Trunc

Statistical functions • Correlation

SAP Sybase IQ 15.4

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Median

• Min

• Multiply

• Stdev

• Sum

• Var

• VarP

• AddDays

• AddMonths
Date and time functions
• CurrentDate

• CurrentDateTime

Copyright © 2023 All Rights Reserved 806


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

Null and Zero functions • IsNull

• NullToZero

Copyright © 2023 All Rights Reserved 807


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ZeroToNull

• FirstInRange

• Lag

• LastInRange

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

• OLAPAvg
OLAP functions
• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningSum

Rank and NTile functions • Rank

String functions • Concat

Copyright © 2023 All Rights Reserved 808


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

Comparison operators • >

• >=

• Begins With

• Between

• Contains

Copyright © 2023 All Rights Reserved 809


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos
Mathematical functions
• Asin

• Atan

Copyright © 2023 All Rights Reserved 810


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan2

• Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions • Correlation

Copyright © 2023 All Rights Reserved 811


Fu n ct io n s Refer en ce

SAP Sybase IQ 16.0

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

Basic functions • Median

• Min

• Multiply

• Stdev

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

Date and time functions • Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 812


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• FirstInRange

• Lag

• LastInRange
OLAP functions
• Lead

• MovingAvg

• MovingCount

Copyright © 2023 All Rights Reserved 813


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr
String functions
• Length

• Lower

• LTrim

• Position

Copyright © 2023 All Rights Reserved 814


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between
Comparison operators
• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

Copyright © 2023 All Rights Reserved 815


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Asin

• Atan

• Atan2

Mathematical functions • Ceiling

• Cos

• Degrees

• Exp

• Floor

• Int

Copyright © 2023 All Rights Reserved 816


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Int2

• Ln

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sqrt

• Tan

• Trunc

Statistical functions • Correlation

Teradata
The tables listed below describe the MicroStrategy function support for
Teradata databases:

l Teradata 12, page 818

l Teradata 13, page 824

l Teradata 13.10, page 830

l Teradata 14.0, page 836

l Teradata 14.10, page 843

Copyright © 2023 All Rights Reserved 817


Fu n ct io n s Refer en ce

Teradata 12

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime
Date and time functions
• Date

• DayOfMonth

• DayOfYear

• DaysBetween

• Hour

Copyright © 2023 All Rights Reserved 818


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

OLAP functions • MovingCount

• MovingMax

• MovingMin

• MovingStdev

Copyright © 2023 All Rights Reserved 819


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length
String functions
• Lower

• LTrim

• Position

• RightStr

• RTrim

Copyright © 2023 All Rights Reserved 820


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 821


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 822


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept
Statistical functions
• InverseFisher

• Kurtosis

• Pearson

• RSquare

Copyright © 2023 All Rights Reserved 823


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Skew

• Slope

• Standardize

• SteYX

Teradata 13

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Max

• Min
Basic functions
• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

Date and time functions • AddMonths

• CurrentDate

Copyright © 2023 All Rights Reserved 824


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

Copyright © 2023 All Rights Reserved 825


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

• OLAPAvg

• OLAPCount

OLAP functions • OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

String functions • ConcatBlank

• InitCap

Copyright © 2023 All Rights Reserved 826


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• LeftStr

• Length

• Lower

• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

Comparison operators • >=

• Begins With

• Between

• Contains

• Ends With

• In

Copyright © 2023 All Rights Reserved 827


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh
Mathematical functions
• Asin

• Asinh

• Atan

Copyright © 2023 All Rights Reserved 828


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

Statistical functions • Correlation

Copyright © 2023 All Rights Reserved 829


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis

• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Teradata 13.10

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean
Basic functions
• Max

• Min

• Multiply

• Product

• Stdev

Copyright © 2023 All Rights Reserved 830


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfYear

• DaysBetween

• Hour

Date and time functions • MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Year

• YearEndDate

• YearStartDate

Copyright © 2023 All Rights Reserved 831


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

• OLAPAvg
OLAP functions
• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

Copyright © 2023 All Rights Reserved 832


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=
Comparison operators
• <>

• =

Copyright © 2023 All Rights Reserved 833


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• >

• >=

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Copyright © 2023 All Rights Reserved 834


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees
Mathematical functions
• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

Copyright © 2023 All Rights Reserved 835


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Teradata 14.0

Function type Functions that can be evaluated on the database

• Add

Basic functions • Average

• Avg

Copyright © 2023 All Rights Reserved 836


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Count

• GeoMean

• Greatest

• Least

• Max

• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date
Date and time functions
• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

• MilliSecond

Copyright © 2023 All Rights Reserved 837


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding

Internal functions • BandingC

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

OLAP functions • MovingCount

• MovingMax

• MovingMin

• MovingStdev

Copyright © 2023 All Rights Reserved 838


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• MovingSum

• OLAPAvg

• OLAPCount

• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length
String functions
• Lower

• LTrim

• Position

• RightStr

• RTrim

Copyright © 2023 All Rights Reserved 839


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>

• =

• >

• >=

• Begins With

• Between

• Contains
Comparison operators
• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

Copyright © 2023 All Rights Reserved 840


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

• Abs

• Acos

• Acosh

• Asin

• Asinh

• Atan

Mathematical functions • Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

Copyright © 2023 All Rights Reserved 841


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

Statistical functions • Intercept

• InverseFisher

• Kurtosis

• Pearson

Copyright © 2023 All Rights Reserved 842


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Teradata 14.10

Function type Functions that can be evaluated on the database

• Add

• Average

• Avg

• Count

• GeoMean

• Greatest

• Least

• Max
Basic functions
• Min

• Multiply

• Product

• Stdev

• StdevP

• Sum

• Var

• VarP

Copyright © 2023 All Rights Reserved 843


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• AddDays

• AddMonths

• CurrentDate

• CurrentDateTime

• CurrentTime

• Date

• DayOfMonth

• DayOfWeek

• DayOfYear

• DaysBetween

• Hour

Date and time functions • MilliSecond

• Minute

• Month

• MonthEndDate

• MonthsBetween

• MonthStartDate

• Quarter

• Second

• Week

• Year

• YearEndDate

• YearStartDate

• Banding
Internal functions
• BandingC

Copyright © 2023 All Rights Reserved 844


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Coalesce

• IsNotNull

• IsNull
Null and Zero functions
• NullToZero

• ZeroToNull

• Lag

• Lead

• MovingAvg

• MovingCount

• MovingMax

• MovingMin

• MovingStdev

• MovingSum

• OLAPAvg

• OLAPCount
OLAP functions
• OLAPMax

• OLAPMin

• OLAPRank

• OLAPSum

• RunningAvg

• RunningCount

• RunningMax

• RunningMin

• RunningStdev

• RunningStdevP

Copyright © 2023 All Rights Reserved 845


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• RunningSum

Rank and NTile functions • Rank

• Concat

• ConcatBlank

• InitCap

• LeftStr

• Length

• Lower
String functions
• LTrim

• Position

• RightStr

• RTrim

• SubStr

• Trim

• -

• x

Arithmetic operators • +

• /

• U-

• <

• <=

• <>
Comparison operators
• =

• >

• >=

Copyright © 2023 All Rights Reserved 846


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Begins With

• Between

• Contains

• Ends With

• In

• Like

• Not Begins With

• Not Between

• Not Contains

• Not Ends With

• Not In

• Not Like

• *<=

• *<>

• *=
Comparison operators for rank
• *>=

• *Between

• Not*Between

• AND

• IF
Logical operators
• Not

• Or

Data mining functions None

Financial functions None

Mathematical functions • Abs

Copyright © 2023 All Rights Reserved 847


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Acos

• Acosh

• Asin

• Asinh

• Atan

• Atan2

• Atanh

• Ceiling

• Cos

• Cosh

• Degrees

• Exp

• Floor

• Int

• Int2

• Ln

• Log

• Log10

• Mod

• Power

• Quotient

• Radians

• Round

• Round2

• Sin

Copyright © 2023 All Rights Reserved 848


Fu n ct io n s Refer en ce

Function type Functions that can be evaluated on the database

• Sinh

• Sqrt

• Tan

• Tanh

• Trunc

• Correlation

• Covariance

• Fisher

• Intercept

• InverseFisher

• Kurtosis
Statistical functions
• Pearson

• RSquare

• Skew

• Slope

• Standardize

• SteYX

Copyright © 2023 All Rights Reserved 849

You might also like