Você está na página 1de 394

MICROSTRATEGY

ANALYTICAL FUNCTIONS
REFERENCE

Version: 7.2.3

Document Number: 09410723

Eighth Edition, May 2003, version 7.2.3


To ensure that you are using the documentation that corresponds to the software you are licensed to use, compare this version number
with the software version shown in About MicroStrategy... in the Help menu of your software.
Document number: 09410723
Copyright 2000-2003 by MicroStrategy Incorporated. All rights reserved.
If you have not executed a written or electronic agreement with MicroStrategy or any authorized MicroStrategy distributor, the following terms apply:
This software and documentation are the proprietary and confidential information of MicroStrategy Incorporated and may not be provided to any other
person. Copyright 2001-2003 by MicroStrategy Incorporated. All rights reserved.
THIS SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT EXPRESS OR LIMITED WARRANTY OF ANY KIND BY EITHER
MICROSTRATEGY INCORPORATED OR ANYONE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION, OR DISTRIBUTION OF THE
SOFTWARE OR DOCUMENTATION, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE, GOOD TITLE AND NONINFRINGMENT, QUALITY OR ACCURACY. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION IS WITH YOU. SHOULD THE SOFTWARE OR DOCUMENTATION PROVE
DEFECTIVE, YOU (AND NOT MICROSTRATEGY, INC. OR ANYONE ELSE WHO HAS BEEN INVOLVED WITH THE CREATION, PRODUCTION, OR
DISTRIBUTION OF THE SOFTWARE OR DOCUMENTATION) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR, OR
CORRECTION. SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO
YOU.
In no event will MicroStrategy, Inc. or any other person involved with the creation, production, or distribution of the Software be liable to you on account
of any claim for damage, including any lost profits, lost savings, or other special, incidental, consequential, or exemplary damages, including but not limited
to any damages assessed against or paid by you to any third party, arising from the use, inability to use, quality, or performance of such Software and
Documentation, even if MicroStrategy, Inc. or any such other person or entity has been advised of the possibility of such damages, or for the claim by any
other party. In addition, MicroStrategy, Inc. or any other person involved in the creation, production, or distribution of the Software shall not be liable for
any claim by you or any other party for damages arising from the use, inability to use, quality, or performance of such Software and Documentation, based
upon principles of contract warranty, negligence, strict liability for the negligence of indemnity or contribution, the failure of any remedy to achieve its
essential purpose, or otherwise. The entire liability of MicroStrategy, Inc. and your exclusive remedy shall not exceed, at the option of MicroStrategy, Inc.,
either a full refund of the price paid, or replacement of the Software. No oral or written information given out expands the liability of MicroStrategy, Inc.
beyond that specified in the above limitation of liability. Some states do not allow the limitation or exclusion of liability for incidental or consequential
damages, so the above limitation may not apply to you.
The information contained in this manual (the Documentation) and the Software are copyrighted and all rights are reserved by MicroStrategy, Inc.
MicroStrategy, Inc. reserves the right to make periodic modifications to the Software or the Documentation without obligation to notify any person or entity
of such revision. Copying, duplicating, selling, or otherwise distributing any part of the Software or Documentation without prior written consent of an
authorized representative of MicroStrategy, Inc. are prohibited. U.S. Government Restricted Rights. It is acknowledged that the Software and
Documentation were developed at private expense, that no part is public domain, and that the Software and Documentation are Commercial Computer
Software provided with RESTRICTED RIGHTS under Federal Acquisition Regulations and agency supplements to them. Use, duplication, or disclosure
by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at
DFAR 252.227-7013 et. seq. or subparagraphs (c)(1) and (2) of the Commercial Computer SoftwareRestricted Rights at FAR 52.227-19, as applicable.
Contractor is MicroStrategy, Inc., 1861 International Drive, McLean, Virginia 22102. Rights are reserved under copyright laws of the United States with
respect to unpublished portions of the Software.
The following are either trademarks or registered trademarks of MicroStrategy Incorporated in the United States and certain other countries: MicroStrategy,
MicroStrategy 6, MicroStrategy 7, MicroStrategy 7i, MicroStrategy 7i Evaluation Edition, MicroStrategy 7i Olap Services, MicroStrategy Administrator,
MicroStrategy Agent, MicroStrategy Architect, MicroStrategy Bi Developer Kit, MicroStrategy Broadcast Server, MicroStrategy Broadcaster, MicroStrategy
Broadcaster Server, MicroStrategy Business Intelligence Platform, MicroStrategy Consulting, MicroStrategy CRM Applications, MicroStrategy Customer
Analyzer, MicroStrategy Desktop, MicroStrategy Desktop Analyst, MicroStrategy Desktop Designer, MicroStrategy eCRM 7, MicroStrategy Education,
MicroStrategy eTrainer, MicroStrategy Executive, MicroStrategy Infocenter, MicroStrategy Intelligence Server, MicroStrategy MDX Adapter, MicroStrategy
Narrowcast Server, MicroStrategy Objects, MicroStrategy OLAP Provider, MicroStrategy SDK, MicroStrategy Support, MicroStrategy Telecaster,
MicroStrategy Transactor, MicroStrategy Web, MicroStrategy Web Business Analyzer, MicroStrategy Web Universal, MicroStrategy World, Alarm,
Alarm.com, Alert.com, Angel, Angel.com, Application Development and Sophisticated Analysis, Best In Business Intelligence, Centralized Application
Management, Changing The Way Government Looks At Information, DSS Agent, DSS Architect, DSS Broadcaster, DSS Broadcaster Server, DSS Office,
DSS Server, DSS Subscriber, DSS Telecaster, DSS Web, eBroadcaster, eCaster, eStrategy, eTelecaster, Information Like Water, Insight Is Everything,
Intelligence Through Every Phone, Intelligence To Every Decision Maker, Intelligent E-Business, IWAPU, Personal Intelligence Network, Personalized
Intelligence Portal, Query Tone, Quickstrike, Rapid Application Development, Strategy.com, Telepath, Telepath Intelligence, Telepath Intelligence (and
Design), The E-Business Intelligence Platform, The Foundation For Intelligent E-Business, The Integrated Business Intelligence Platform Built For The
Enterprise, The Intelligence Company, The Platform For Intelligent E-Business, The Power Of Intelligent eBusiness, The Power Of Intelligent E-Business,
and The Scalable Business Intelligence Platform Built For The Internet . Other product and company names mentioned herein may be the trademarks of
their respective owners.
This product is patented. One or more of the following patents may apply to the product sold herein: US Patent Nos. 6,279,033, 6,269,393, 6,263,051,
6,173,310, 6,154,766, 6,260,050, 6,501,832, 6,567,796. Other patent applications are pending.
Various MicroStrategy products contain the copyrighted technology of third parties. This product may contain one or more of the following copyrighted
technologies:
Graph Generation Engine Copyright 1998-2003. Three D Graphics, Inc. All rights reserved.
Actuate Formula One. Copyright 1993-2003 Actuate Corporation. All rights reserved.
XML parser Copyright 2003 Microsoft Corporation. All rights reserved.
Xalan XSLT processor. Copyright 1999-2003. The Apache Software Foundation. All rights reserved.
Xerces XML parser. Copyright 1999-2003. The Apache Software Foundation. All rights reserved.
FOP XSL formatting objects. Copyright 2003. The Apache Software Foundation. All rights reserved.
Portions of Intelligence Server memory management Copyright 1991-2002 Compuware Corporation. All rights reserved.
International Components for Unicode
Copyright 1999-2003 Compaq Computer Corporation
Copyright 1999-2003 Hewlett-Packard Company
Copyright 1999-2003 IBM Corporation
Copyright 1999-2003 Hummingbird Communications Ltd.
Copyright 1999-2003 Silicon Graphics, Inc.
Copyright 1999-2003 Sun Microsystems, Inc.
Copyright 1999-2003 The Open Group
All rights reserved.
Real Player and RealJukebox are included under license from Real Networks, Inc. Copyright 1999-2003. All rights reserved.

CONTENTS
Document description .............................................................. xiii
Who Should Use this Guide................................................... xiv
Prerequisites .......................................................................... xiv
Objectives .............................................................................. xiv
About this Book............................................................................xiv
Typographical standards ............................................................ xvii
For online and printed documentation .................................. xvii
For printed documentation only ............................................ xvii
Resources.....................................................................................xx
Product documentation ...........................................................xx
Online documentation .............................................................xx
International support .................................................................. xxiii
User assistance ......................................................................... xxiv
Online help........................................................................... xxiv
Technical Support ................................................................ xxiv
Feedback ................................................................................... xxix

1. Overview

Introduction .................................................................................. 1
Metrics in MicroStrategy 7i ............................................................ 2
Metric formulae .............................................................................. 3
Facts ........................................................................................ 3
Functions ................................................................................. 4
Function Parameters ............................................................. 10
Terminology and notation in metric functions ........................ 11
Metric notation and syntax ..................................................... 12
The MicroStrategy 7i engine........................................................ 16

2003 MicroStrategy, Inc.

iii

Contents

MicroStrategy Analytical Functions Reference

Structure ................................................................................ 16
How Intelligence Server uses functions....................................... 17
Business Case Examples ............................................................ 39
Defining custom plug-in functions................................................ 95

2. Banding Functions

Introduction ................................................................................ 97
Banding........................................................................................ 98
BandingC ..................................................................................... 98
BandingP ..................................................................................... 99
Banding qualification in custom groups ....................................... 99
Examples ................................................................................... 100
Case 1 ................................................................................. 101
Case 2 ................................................................................. 102
Case 3 ................................................................................. 103
Case 4 ................................................................................. 104

3. Basic Functions

Introduction .............................................................................. 105


Average ..................................................................................... 106
Count ......................................................................................... 106
First............................................................................................ 107
Geometric mean ........................................................................ 108
Greatest ..................................................................................... 109
Last ............................................................................................ 109
Least .......................................................................................... 110
Maximum ................................................................................... 111
Median ....................................................................................... 111
Minimum .................................................................................... 112
Mode.......................................................................................... 113
Product ...................................................................................... 114
Standard deviation (of a population).......................................... 115
Standard deviation (of a sample)............................................... 116
Sum ........................................................................................... 117
Variance of a population ............................................................ 118
Variance of a sample ................................................................. 119

iv

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

4. Date Functions

Contents

Introduction .............................................................................. 121


Current Date .............................................................................. 122
Day of the Month ....................................................................... 123
Day of the Week ........................................................................ 124
Day of the Year.......................................................................... 125
Week.......................................................................................... 126
Month......................................................................................... 127
Quarter....................................................................................... 128
Year ........................................................................................... 129
Current Date and Time .............................................................. 130
Current Time .............................................................................. 131
Hour ........................................................................................... 132
Minute ........................................................................................ 133
Second....................................................................................... 134
Millisecond ................................................................................. 135

5. Finance Functions

Introduction .............................................................................. 137


Accrued interest......................................................................... 138
Accrued interest at maturity ....................................................... 140
Amount received at maturity ...................................................... 141
Coupon, number payable between settlement and maturity ..... 143
Coupon date, next (after settlement) ......................................... 144
Coupon date, previous (before settlement) ............................... 146
Coupon period, beginning to settlement .................................... 147
Coupon period, number of days with settlement ....................... 149
Coupon period, settlement to next coupon ................................ 150
Cumulative interest paid ............................................................ 151
Cumulative principal paid........................................................... 153
Dollar price, converted from fraction to decimal ........................ 154
Dollar price, converted from decimal to fraction ........................ 155
Double-declining balance (asset depreciation) .......................... 155
Discount rate for a security ........................................................ 156
Duration ..................................................................................... 158
Effective annual interest rate ..................................................... 159

2003 MicroStrategy, Inc.

Contents

MicroStrategy Analytical Functions Reference

Fixed-declining balance (asset depreciation) ............................ 160


Future value............................................................................... 162
Future value schedule ............................................................... 163
Interest payment ........................................................................ 164
Interest rate................................................................................ 165
Interest rate per period .............................................................. 166
Internal rate of return ................................................................. 168
Modified duration ....................................................................... 169
Modified internal rate of return................................................... 171
Net present value (of an investment) ......................................... 172
Nominal annual interest rate...................................................... 173
Number of investment periods................................................... 174
Odd-first-period price ................................................................. 175
Odd-first-period yield ................................................................. 177
Odd-last-period price ................................................................. 179
Odd-last-period yield.................................................................. 181
Payment..................................................................................... 182
Present value............................................................................. 183
Price at maturity ......................................................................... 184
Price, discounted ....................................................................... 186
Price per $100 face value .......................................................... 188
Principle payment ...................................................................... 190
Straight-line depreciation ........................................................... 191
Sum of years digits depreciation............................................... 192
T-bill equity ................................................................................ 193
T-bill price .................................................................................. 194
T-bill yield................................................................................... 195
Variable declining balance......................................................... 196
Yield........................................................................................... 197
Yield at maturity ......................................................................... 199
Yield on a discounted security ................................................... 201

6. Internal Functions

Introduction .............................................................................. 203


Pass-through functions .............................................................. 203

vi

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Contents

Pass-through function syntax and usage............................. 204


Case .......................................................................................... 206
Case Value ................................................................................ 207

7. Mathematical
Functions

Introduction .............................................................................. 209


Absolute value ........................................................................... 210
Arc Cosine ................................................................................. 210
Arc Sine ..................................................................................... 211
Arc Tangent ............................................................................... 212
Arc Tangent 2 ............................................................................ 213
Ceiling value .............................................................................. 214
Combination............................................................................... 215
Cosine........................................................................................ 216
Cosine, hyperbolic ..................................................................... 217
Degrees (conversion to) ............................................................ 218
Exponent.................................................................................... 218
Factorial ..................................................................................... 219
Floor value ................................................................................. 220
Integer........................................................................................ 220
Logarithm................................................................................... 221
Logarithm, base 10 .................................................................... 222
Logarithm, natural...................................................................... 222
Power......................................................................................... 224
Quotient ..................................................................................... 225
Radians (conversion to)............................................................. 225
Random number (between two values) ..................................... 226
Sine............................................................................................ 227
Sine, hyperbolic ......................................................................... 227
Square root ................................................................................ 228
Tangent...................................................................................... 229
Tangent, hyperbolic ................................................................... 230
Truncate..................................................................................... 231

2003 MicroStrategy, Inc.

vii

Contents

8. Null and Zero


Functions

MicroStrategy Analytical Functions Reference

Introduction .............................................................................. 233


Is Not Null .................................................................................. 234
Is Null......................................................................................... 235
Null to Zero ................................................................................ 236
Zero to Null ................................................................................ 236

9. OLAP Functions

Introduction .............................................................................. 237


Exponential weight moving average .......................................... 238
Exponential weight running average.......................................... 238
First value in range .................................................................... 239
Last value in range .................................................................... 240
Moving average ......................................................................... 241
Moving count ............................................................................. 242
Moving difference ...................................................................... 243
Moving maximum....................................................................... 244
Moving minimum........................................................................ 245
Moving standard deviation (of a population) .............................. 246
Moving standard deviation (of a sample)................................... 247
Moving sum ............................................................................... 248
Running average ....................................................................... 249
Running count............................................................................ 250
Running maximum..................................................................... 251
Running minimum ...................................................................... 252
Running standard deviation (of a population) ............................ 253
Running standard deviation (of a sample) ................................. 254
Running sum.............................................................................. 255

10. Rank and Tile


Functions

Introduction .............................................................................. 257


N-Tile ......................................................................................... 258
N-Tile Step Size......................................................................... 259
N-Tile Value ............................................................................... 260
N-Tile Value Step Size............................................................... 261
Percentile................................................................................... 261
Rank by Value ........................................................................... 262

viii

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Contents

Rank by Percent ........................................................................ 263

11. Statistical Functions

Introduction .............................................................................. 265


Average deviation ...................................................................... 266
Beta distribution ......................................................................... 267
Beta distribution, inverse of ....................................................... 268
Binomial distribution................................................................... 269
Chi-square distribution ............................................................... 270
Chi-squared distribution, inverse of ........................................... 271
Chi-square test for independence.............................................. 273
Confidence interval .................................................................... 274
Correlation ................................................................................. 276
Covariance................................................................................. 278
Criterion binomial....................................................................... 279
Exponential distribution.............................................................. 280
Fisher transformation................................................................. 281
Fisher transformation, inverse of ............................................... 282
F-probability distribution............................................................. 283
F-probability distribution, inverse of ........................................... 284
F-test.......................................................................................... 285
Gamma distribution.................................................................... 286
Gamma distribution, inverse of .................................................. 288
Gamma distribution, logarithm of............................................... 289
Hypergeometric distribution ....................................................... 290
Intercept..................................................................................... 291
Kurtosis...................................................................................... 292
Lognormal distribution ............................................................... 293
Lognormal distribution, inverse of.............................................. 294
Negative binomial distribution .................................................... 295
Normal cumulative distribution................................................... 297
Normal cumulative distribution, inverse of ................................. 298
Pearson product moment correlation coefficient ....................... 299
Pearson product moment correlation coefficient, square of ...... 300
Permutation ............................................................................... 301

2003 MicroStrategy, Inc.

ix

Contents

MicroStrategy Analytical Functions Reference

Poisson distribution.................................................................... 302


Skew .......................................................................................... 304
Slope (of a linear regression)..................................................... 305
Standard error of estimates ....................................................... 306
Standardize................................................................................ 307
Standard normal cumulative distribution.................................... 308
Standard normal cumulative distribution, inverse of .................. 309
T-distribution .............................................................................. 310
T-distribution, inverse of ............................................................ 311
T-test, mean............................................................................... 312
T-test, paired two-sample (for means)....................................... 314
T-test, two-sample ..................................................................... 316
Variance test.............................................................................. 318
Weibull distribution..................................................................... 319

12. String Functions

Introduction .............................................................................. 321


Concatenate .............................................................................. 322
Concatenate with a Blank .......................................................... 323
Initial Cap................................................................................... 324
Length ........................................................................................ 325
Lower Case................................................................................ 326
Position of first occurrence ........................................................ 327
String (from the inputs) Left ...................................................... 328
String (from the inputs) Right .................................................... 329
Substring.................................................................................... 330
Trim............................................................................................ 331
Trim Left..................................................................................... 332
Trim Right .................................................................................. 333
Upper Case................................................................................ 334

A. Database Support for


MicroStrategy
Functions

Introduction .............................................................................. 335


Access ....................................................................................... 336
DB2 ............................................................................................ 336
Datajoiner .................................................................................. 339

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Contents

Informix ...................................................................................... 340


Oracle ........................................................................................ 342
Redbrick..................................................................................... 344
SQL Server ................................................................................ 346
Sybase....................................................................................... 347
Tandem...................................................................................... 349
Teradata .................................................................................... 350

Index ......................................................................................... 353

2003 MicroStrategy, Inc.

xi

Contents

xii

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

PREFACE
Document description
In the context of MicroStrategy 7i, engine functions are based
on the capabilities the system offers for handling
user-selected calculations. These calculations are
measurements applied to business data and they constitute
the basis of MicroStrategy 7i metrics. The information in this
book includes

2003 MicroStrategy, Inc.

metric-related notions essential to understanding how


engine functions work and how they can be used.

an overview of the MicroStrategy 7i engine.

a list of the function types described in this document,


and how functions are accessed from the Desktop
interface.

an explanation of the notation conventions used for


function syntax descriptions.

xiii

Preface

MicroStrategy Analytical Functions Reference

Who Should Use this Guide


This document is designed for any user who needs to create a
metric or calculation using any of the pre-defined analytical
functions MicroStrategy offers.

Prerequisites
Before reading this document, you should be familiar with

basic MicroStrategy terminology like metrics, facts,


attributes, and so on

standard mathematical function notation

Objectives
After reading this manual, you will be able to use any of the
pre-defined analytical functions in metris definitions.

About this Book


This book is divided into chapters and reference appendices.
The chapters provide concepts and reference information for
the different categories of analytical functions that
MicroStrategy provides.
Each chapter begins with a brief overview of the content. The
chapter is then divided into subsections organized in the best
method to promote learning. If applicable, a series of steps is
provided to carry out the task description and facilitate the
learning process.
The information in this document has been organized by
function type and, within each type, by description of each
specific function.

xiv Who Should Use this Guide

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

Function Types
For the purposes of this document, functions have been
broken into the following major categories:

banding

basic

date and time

finance

mathematics

null and zero

OLAP

pass-through

rank

statistics

string

Each of these function categories is a separate chapter.

Function descriptions
For every function identified, the description includes:

2003 MicroStrategy, Inc.

function name

information returned

function syntax

(as applicable) notes regarding restrictions or conditions


on execution and use

(as applicable) a list of the databases that support the


function

About this Book

xv

Preface

MicroStrategy Analytical Functions Reference

Syntax notation
Throughout this document, conventions used for syntax
notation are as follows:
Character

Parameter type

Numeric. Specific data type depends on the database.


Examples: INTEGER, FLOAT, DOUBLE, DECIMAL,
NUMERIC. For values not associated with a specific
unit, lower case (n) is used.

String. Specific data type depends on the database.


Examples: CHAR, VCHAR, TEXT.

Date. Specific data type depends on the database.


Examples: DATE, DATETIME, TIMESTAMP.

Time. Specific data type depends on the database.


Examples: TIME, DATETIME, TIMESTAMP.

Function Access
To access MicroStrategy 7i functions:

1 In the MicroStrategy 7i primary window, on the File


menu, point to New, and then choose Metric to open the
Metric Editor.
2 Select Functions and Operators from the shortcut bar
on the Metric Editor primary window.
3 Open one of the following folders:
Functions, to use a Basic, OLAP, or Rank function
Plug-In Packages, to use a Mathematics, Finance, or
Statistics function
Operators, to select an arithmetical, comparison, or
logical operator
For more information on metrics in MicroStrategy 7i, see the
Metrics chapter in the MicroStrategy 7i Advanced
Reporting Guide.

xvi About this Book

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

Typographical standards
For online and printed documentation
MicroStrategy online and hard copy documentation follows
presentation conventions and cues to help you locate,
identify, and understand important concepts and procedures.
The following table lists these conventions.
Type

Indicates

bold

button names, check boxes, dialog boxes,


options, lists, and menus that are the focus of
actions or part of a list of such GUI elements and
their definitions
text to be entered by the user

italic

new terms defined within the text and in the


glossary
names of other product manuals
when part of a command syntax, indicates
variable information to be replaced by the user

Courier
font

UPPERCASE

keyboard command key (such as ENTER)


shortcut key (such as CTRL+V)

calculations
code samples
registry keys
path and file names
URLs
messages displayed in the screen

A keyboard command that calls for the use of more


than one key (for example, SHIFT+F1)

For printed documentation only


The following are explanations of the font style changes,
icons, and different types of notes that you may see in this
user guide.

2003 MicroStrategy, Inc.

Typographical standards

xvii

Preface

MicroStrategy Analytical Functions Reference

Actions
References to screen elements and keys that are the focus of
actions are in bold Arial font style. Following is an example:
1 Click Select Warehouse.

Code
References to code, formulas, or calculations within
paragraphs are formatted in regular Courier New font style.
Following is an example:
Sum(sales)/number of months

Data entry
References to literal data you must type in an exercise or
procedure are in bold Arial font style. References to data you
type in that could vary from user to user or system to system
are in bold italic Arial font style. Following is an example:
Type cmdmgr -f scriptfile.scp and press ENTER.
Type copy c:\filename d:\foldername\filename

Keyboard keys
References to a keyboard key or shortcut keys are in
uppercase letters. Following is an example:
To bold the selected text, press CTRL+B.

New terms
New terms to note are in regular italic font style. These terms
are defined when they are first encountered in the course
material. Following is an example:

xviii Typographical standards

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

The aggregation level is the level of calculation for the


metric.

Notes and warnings

* This note icon indicates helpful information.


warning icon calls your attention to very
+ This
important information that should be read before
continuing.

Heading icons
The following heading icons are used to indicate specific
practice and review sections:

Precedes a Case Study. Cases Studies are real-life examples


from companies that are using MicroStrategy products.

Precedes a Business Scenario. Business Scenarios are


examples from the MicroStrategy Tutorial. They explain how
to accomplish complex tasks using MicroStrategy 7i.

2003 MicroStrategy, Inc.

Typographical standards

xix

Preface

MicroStrategy Analytical Functions Reference

Resources
Product documentation
MicroStrategy 7i includes a full set of product manuals,
designed to help you find the information you need to install,
configure, design, and administer your business intelligence
and narrowcast systems, as well as full SDK documentation
to help you extend and customize MicroStrategy and
integrate it with your existing applications.
A list of documentation links is available to access all
documentation installed from your CD-ROM. Most of these
documents have been provided in Acrobat Portable
Document Format (PDF).
Acrobat Reader is required to view these
* Adobe
documents. If you do not have Acrobat Reader

installed on your computer, you can download it from


http://www.adobe.com or install it directly from
the MicroStrategy product CD.

Online documentation
To access an online manual

1 On the Windows Start menu, point to Programs, then to


MicroStrategy 7, and then choose Product Manuals. A
Web page opens with a list of manuals in PDF format.
2 Click the link for the desired manual.
3 Some information is provided in HTML help format.
When you select one of these guides, the Download file
dialog box will open. Select the Open this file from its
current location option and click OK.

xx Resources

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

bookmarks are not visible on the left side of an


* IfAcrobat
document, select Bookmarks and Page from
the View menu, then select the topic and section you
want to see. You can also scroll from the title page of
the guide to its table of contents, and select from there
the topic you want to read.

The following documents are provided on your CD-ROM in


PDF format:

MicroStrategy 7i Overview

Introduction to MicroStrategy 7i: Evaluation Guide

MicroStrategy 7i Quick Start Guide

Manuals for Query, Reporting, and Analysis


Products

2003 MicroStrategy, Inc.

MicroStrategy Basic Setup Guide

MicroStrategy Advanced Reporting Guide

MicroStrategy System Administration Guide

MicroStrategy Analytical Functions Reference

MicroStrategy Web Customization Guide

MicroStrategy Web Universal Installation and


Deployment Guide

MicroStrategy Intelligence Server, Architect, and


Administrator Upgrade Guide

MicroStrategy MDX Adapter System Guide

MicroStrategy MDX Adapter Language Reference


Manual

MicroStrategy MDX Adapter OBDO Properties


Reference Manual

Resources

xxi

Preface

MicroStrategy Analytical Functions Reference

Manuals for Information Delivery and Alerting


Products

MicroStrategy Narrowcast Server Getting Started Guide

MicroStrategy Narrowcast Server Installation and


Configuration Guide

MicroStrategy Narrowcast Server Application Designer


Guide

MicroStrategy Narrowcast Server System


Administrator Guide

MicroStrategy Narrowcast Server Upgrade Guide

Manuals for Database Writeback Product

MicroStrategy Transactor Installation and


Administration Guide

MicroStrategy Transactor Developer Guide

Manuals for Analytics Modules

xxii Resources

Best Practices Designing and Building Portable


Analytical Applications

Implementing MicroStrategy Analytics


ModulesPortability Methodology

Customer AnalysisReference

Sales AnalysisReference

Getting started with MicroStrategy Web Traffic Analysis


Module

Web Traffic AnalysisReference

Financial Reporting AnalysisReference

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

Software Development Kits

MicroStrategy SDK for Intelligence Server and Web


Developer Guide: Common Functions

MicroStrategy SDK for Intelligence Server and Web


Developer Guide: Extended Functions

MicroStrategy SDK for Web Developer Guide: Web


Application Development

Narrowcast Server SDK Guide

International support
MicroStrategy 7i supports several locales. Support for a locale
typically includes native database and operating system
support, support for date formats, decimal formats, currency
symbols etc. and availability of translated interfaces and
documentation. The level of support is defined in terms of the
components of a MicroStrategy 7i Business Intelligence
environment. A MicroStrategy 7i Business Intelligence
environment consists of the following components,
collectively known as a configuration:

warehouse, metadata, and statistics databases

MicroStrategy Intelligence Server

MicroStrategy Web Server

MicroStrategy Desktop client

Web browser

MicroStrategy 7i is certified in homogeneous configurations


(where all the components lie in the same locale) in the
following languagesEnglish (US), French, German, Italian,
Japanese, Korean, Portuguese (Brazilian), Spanish, and
Swedish.
MicroStrategy 7i also provides limited support for
heterogeneous configurations (where some of the
components may lie in different locales). Please contact
MicroStrategy Technical Support for more details.

2003 MicroStrategy, Inc.

International support

xxiii

Preface

MicroStrategy Analytical Functions Reference

A translated user interface is available in each of the above


languages. In addition, translated versions of the online help
files and product documentation are available in several of
the above languages.

User assistance
The following paragraphs describe the types of assistance
available to answer questions you may have regarding
MicroStrategy 7i products.

Online help
MicroStrategy 7i provides several modes of access to online
help:

From the Help menu, by selecting Contents and Index to


see the main table of contents for the help system

By pressing F1 to see context-sensitive help addressing


the function or task you are currently performing

Technical Support
If you have questions about a specific MicroStrategy product,
you should:
1 Consult the product guides, online help, readme files, and
release notes
2 Consult the online knowledge base at
http://www.microstrategy.com/support/
k_base
technical administrator in your organization can
* Aprobably
help you resolve some of your issues
immediately.

xxiv User assistance

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

3 If the resources listed in steps 1 and 2 do not provide you


with a solution, contact MicroStrategy Technical Support
directly. To ensure the most effective and productive
relationship with MicroStrategy Technical Support,
review the Policies and Procedures document posted at
http://www.microstrategy.com/Support/
Policies.asp. Please refer to the terms of your
purchase agreement to determine the type of support
available to you.
The table on the following page shows where, when, and how
to contact MicroStrategy Technical Support. If you are unable
to reach MicroStrategy Technical Support by phone during
the hours of operation, you have the option to leave a
voicemail message or send electronic mail.

2003 MicroStrategy, Inc.

User assistance

xxv

Preface

xxvi User assistance

MicroStrategy Analytical Functions Reference

Americas
(US and
Canada)

Hours of operation:
MondayFriday: 9:00 A.M.7:00 P.M. Eastern Time (14000000
GMT)
Phone: (703) 8488700
Fax: (703) 8488710
Electronic mail: support@microstrategy.com
Web: http://support.microstrategy.com

Europe,
Middle East,
and Africa

Hours of operation: MondayFriday:


UK: 9:00 A.M.6:00 P.M. GMT
Mainland Europe: 9:00 A.M.6:00 P.M. CET
The European Technical Support Centre is closed on certain
public holidays. These holidays reflect the national public
holidays in each country.
Direct support phone lines:
United Kingdom: +44 (0) 1753 826198
Belgium, Netherlands, Luxembourg: +31 20 346 9210
France: +33 1 41 91 86 49
Germany: +49 69 95096206
Italy: +39 02696 33 456
Spain: +34 91 406 9010
International distributors: +44 (0) 1753 826199
Fax: +44 (0) 1753 826101
Electronic mail: eurosupp@microstrategy.com
Web: http://support.microstrategy.com

Asia and
Pacific

Hours of operation:
Sunday-Thursday 6:00 P.M.-3:00 A.M. Eastern Time
(23000800 GMT)
Phone: (703) 7446469
Fax: (703) 8488710
Electronic mail: apsupport@microstrategy.com
Web: http://support.microstrategy.com

Brazil

Hours of operation:
MondayFriday: 9:00 A.M.6:00 P.M.
Phone: (5511) 3045-1725
Fax: (5511) 30444088
Electronic mail: support@microstrategy.com
Web: http://support.microstrategy.com

Argentina

Hours of operation:
MondayFriday: 9:00 A.M.6:00 P.M.
Phone: (5411) 52229300
Fax: (5411) 52229355
Electronic mail: support@microstrategy.com
Web: http://support.microstrategy.com

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

When contacting MicroStrategy Technical Support, please


provide the following information:

your name (first and last)

the name of your company

If this is your first call, you should also be prepared to provide


the following:

street address

phone number

fax number

e-mail address

To help your Technical Support representative work with you


to resolve the problem promptly and effectively, be prepared
to provide the following additional information:

2003 MicroStrategy, Inc.

issue numberplease keep a record of the number


assigned to each problem logged with MicroStrategy
Technical Support, and be ready to provide it when
inquiring about an existing issue

software version and product registration numbers of the


MicroStrategy software products you are using

User assistance

xxvii

Preface

MicroStrategy Analytical Functions Reference

Problem description:
What causes the condition to occur?
Does the condition occur sporadically or each time a
certain action is performed?
Does the condition occur on all machines or just on
one?
When did the condition first occur?
What events took place immediately prior to the first
occurrence of the condition (for example, a major
database load, a database move, a software upgrade)?
If there was an error message, what was its exact
wording?
What steps have you taken to isolate and resolve the
issue? What were the results?
System configuration (the information needed for this
purpose depends on the nature of the problem; not all
items listed may be necessary):
computer hardware specifications (processor speed,
RAM, disk space, and so on)
network protocol used
ODBC driver manufacturer and version
database gateway software version
(for MicroStrategy Web-related problems) browser
manufacturer and version
(for MicroStrategy Web-related problems) Web server
manufacturer and version

If the issue requires additional investigation or testing, you


and the MicroStrategy Technical Support representative
should agree on certain action items to be performed. You
should perform any agreed-upon actions before contacting
Technical Support again regarding the issue. If the Technical
Support representative is responsible for an action item, you
may call Technical Support at any time to inquire about the
status of the issue.

xxviii User assistance

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Preface

Feedback
Please send any comments or suggestions about user
documentation for MicroStrategy 7i products to:
documents@microstrategy.com
Send suggestions for product enhancements to:
support@microstrategy.com
When you provide feedback to us, please include the name
and version of the products you are currently using. Your
feedback is important to us as we prepare for future releases.

2003 MicroStrategy, Inc.

Feedback

xxix

Preface

xxx Feedback

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

1
OVERVIEW

Introduction
In the context of MicroStrategy 7i, functions are based on the
capabilities the system offers for handling user-selected
calculations. These calculations are, in fact, measurements
applied to business data, and constitute the basis of
MicroStrategy 7i metrics. This chapter covers the following:

2003 MicroStrategy, Inc.

metric-related notions essential to understanding how


functions work and how they can be used

an overview of the MicroStrategy 7i engine

a list of the function types described in this document,


and how functions are accessed from the Desktop
interface

an explanation of the notation conventions used for


function syntax descriptions

some business case examples to describe the usage of


functions in Intelligence Server

an overview on defining custom plug-in functions

Overview

MicroStrategy Analytical Functions Reference

Metrics in MicroStrategy 7i
Metrics, in a MicroStrategy 7i environment, belong to one of
the following categories:

Simple metrics can stand alone or be used as building


blocks for compound metrics. Simple metrics always have
a formula and a level. The entire metric can only contain
one level.
A simple metric does not restrict you to simple
calculations; the term simple only refers to its structure. A
simple metric consists of a formula and a level. A formula
is a mathematical expression based on at least one group
function, such as sum or average, applied to facts,
attributes, or metrics. A simple metric can also contain a
non-group function or arithmetic operator, in addition to
the required group function. However, it must be placed
inside the group function, as demonstrated by the
following examples:
Sum(Revenue - Cost){~+}
Sum(Abs (Revenue - Cost)){~+}
The level, or dimensionality, is the level of calculation for
the metric, such as year or customer. Simple metrics can
also contain filtering, called a condition, or offset values,
called transformations. These are not required
components, as are the formula and level.

Compound metrics cannot have a level placed on the


entire metric, although it can be set separately on each of
the components.
A metric that is not a simple metric is, by default, a
compound one. The most important distinction is that
compound metrics cannot have a level placed on the
entire metric, although the level can be set separately on
each of the components. A compound metric is a
combination of expressions that, through the use of
functions, are themselves metrics. For example, the
Revenue Metric is a simple metric defined as:
Sum(Revenue){~+}

2 Metrics in MicroStrategy 7i

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

A compound metric can contain the Revenue Metric as


shown below:
Rank([Revenue Metric])
Note that no level is set and Rank is a non-group function.
A compound metric can also include expressions that act
as metrics, such as:
(Avg [Revenue] {Year+ }) + (Avg[Cost] {Year+ )
Notice that while both the average functions have a level
(Year), the metric as a whole does not. Compound metrics
can contain prompts and constant numerical values, but
cannot include conditions, levels, or transformations
except for those already part of the simple metric they
contain.
This classification affects the way in which a metric is defined
and, by extension, the notation used in that definition. There
are certain generic metric components whose purpose and
notation, described in the paragraphs that follow, apply to all
metrics, and may serve to better explain how functions are
defined and executed.

Metric formulae
The metric component that determines the way in which a
given input is calculated in MicroStrategy 7i is known as the
metric formula. The descriptions that follow provide working
definitions of formula contents.

Facts
Represented as arrays of data or vectors in the context of
functions, facts are obtained from specific columns in a fact
table, and denoted in syntax statements in bold characters
(X), sometimes within square brackets ([X]).

2003 MicroStrategy, Inc.

Metric formulae

Overview

MicroStrategy Analytical Functions Reference

Functions
We can classify all the operators/functions in Intelligence
Server into one of the following categories:

Group-value functions (also known as Grouping


functions, or Aggregate functions). These terms will be
used interchangeably. Examples of this category are: Avg,
AvgDev, Correlation, Count, HomoscedasticTTest,
Intercept, Slope, StDev, Sum, and so on.

Single-value functions (also known as Non-grouping


functions, or Scalar functions). Examples of this category
are: Abs, Accrint, Ddb, Cos, Ln, Round, Truncate, and so
on.

In addition to the two categories mentioned above,


Intelligence Server also recognizes the following type of
function:

Relative functions (ANSI OLAP functions). Examples of


this category are: Rank, RunningSum, MovingAvg, and so
on.

The following sections discuss each category from a


mathematical perspective.

Group-value function
Consider the following examples of group-value functions.
Example 1:
Consider a function defined as:
n

y = f ( x ) = xi = x1 + x 2 + ... + x n
i =1

y = f (x) is a function that is performed on an input vector x.


We use a sum operator to obtain the scalar y as an output.

The sum operator is denoted by

4 Metric formulae

= sigma
2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

For example, if we provide an input vector xT = [10 8 12 15


25] to the above function, then the resultant scalar output
will be y = 10 + 8 + 12 + 15 + 25 = 70.
Example 2:
Furthermore, if we define an input as a vector wT = [uT vT ]
where uT = [10 8 12 ] and vT = [15 25], and we want a
similar function, that is,
n

y = f (x ) = xi
i =1

to be applied to both u and v, then the resultant output will


be zT = [30 40].
Functions in Examples 01 and 02 are said to be grouping
functions since they take one or more vectors from every
input variable and map it to one or more scalars. In Example
1, it takes whole vector x and maps it to a scalar y. In Example
2, it takes a vector u as input which is a part of the whole
input vector w and maps it to 30. It also takes a vector v as
input which is also a part of vector w and maps it to 40.
A characteristic of these grouping functions is that the
cardinality of output is never greater than the cardinality of
the input. In mathematical terms, cardinality means the
number of elements. In Example 1, the input x has cardinality
of 5, that is, |x|=5 and the output y has cardinality of 1, that
is, |y|=1. In Example 2, the input w has cardinality of 5 and
the output z has cardinality of 2.
Moreover, we can also denote the sigma notation in the above
examples as an operator. In database computation, the above
function is represented by the Sum operator. The Intelligence
Server recognizes a Simple Metric by defining it as
Sum([Revenue]) {~+}. Notice that [Revenue] is a fact (an
input vector), the Sum is a grouping function, and {~+}
represents the level of aggregation of the metric.
One important point to note here is the concept of group by.
Since Sum is a group-value function, it operates on the fact
(that is, a vector) [Revenue] to produce a scalar output for
each attribute elements. This reduces the cardinality for the
output. Consider the following examples.

2003 MicroStrategy, Inc.

Metric formulae

Overview

MicroStrategy Analytical Functions Reference

Example 3:
Consider a function that is defined as:
n

y = f (x) =

x
i =1

-x
= AvgDev ( x )

This is a group-value function since it operates on a vector


from a variable x (hence, it reduces the cardinality of input
vectors) to produce a scalar output y.
Example 4:
Consider a function that is defined as:

z = f (x, y ) =

n
n n
n xi y i - xi yi
i =1
i =1 i =1
2
2
n
n
n
n

n x 2 - x n y 2 - y
i =1 i i =1 i i =1 i i =1 i

which is the same as


RSquare(x, y ) =

n
n n
n xi y i - xi y i
i =1
i =1 i =1

2
2
n
n
n
n

n x 2 - x n y 2 - y
i =1 i i =1 i i =1 i i =1 i

Again, this is a group-value function since it operates on two


vectors: vectors x and y (hence, it reduces the cardinality of
input vectors) to produce a scalar output z.
From this perspective, it should be clear that there is no
difference between Sum and AvgDev or RSquare. All are
group-value functions that can be used to build a simple
metric. In Intelligence Server, these functions can be applied
to facts for report analysis. The usage of each function will
differ based on the business case scenario.

6 Metric formulae

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

However, it should be noted that the Sum function can be


performed by all databases, while the AvgDev function will
be computed only by Intelligence Server since no database
supports this function. Some databases (DB2 UDB, and
Teradata) support RSquare while others (Oracle and SQL
Server) do not support it. One of the many advantages that
the Intelligence Server offers is that it will calculate any
functions not supported by the database platform.

Single-value function
Consider the following examples of single-value functions.
Example 5:
Consider another function defined as:
z = f ( x, y ) =

x
y

In this example, the function z = f (x,y) takes two input


variables, namely x and y and uses the division operator to
obtain an output. However, notice that both x and y are not
vectors. They are scalars. If we provide scalar inputs as x = 7
and y = 8, then we will get another scalar as output:
z=

7
= 0.875
8

Example 6:
Consider now input vectors xT = [7 5 10] and yT = [8 4 3].
We want the same operation (division) to be applied to inputs
x and y. Now it has to be performed element by element. The
result will be an output vector zT = [0.875 1.250 3.333]

2003 MicroStrategy, Inc.

Metric formulae

Overview

MicroStrategy Analytical Functions Reference

This type of function is classified as a single-value function


since it maps a scalar from every input variable to another
scalar. This is equivalent to saying that this class of function
does not change the cardinality of inputs. Notice that in
Example 5, cardinality of both inputs (x and y) equals 1 and
cardinality of output (z) is also 1. In Example 6, cardinality of
all vectors (x, y, and z) is the same, that is, 3.
The operator used in Examples 5 and 6 is division (that is, /).
This type of operator/function is commonly used to build a
compound metric. In general, there are other operators that
share this characteristic (that is, they do not change the
cardinality of inputs. The following function is an example of
non-grouping types).
Example 7:
Consider functions that are defined as:
z = Log(x), z = InverseNormSDistribution(x)
z = Randbetween(x,y)
z = Fv(Rate, Nper, Pmt, Pv)
These functions are non-aggregation functions since they
operate on each element from each variable. That is, in the
case of functions Log and InverseNormSDistribution, they
take 1 element from one variable (x), and in the case of
functions Randbetween and Fv, they take 1 element from
each variable (x, y) or (Rate, Nper, Pmt, Pv). Note that the
cardinality of input never changes.

8 Metric formulae

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Relative function
Consider the following examples of relative functions.
Example 8:
Consider the following mapping.
A3

a3,1
a
3,1
a3,1
a
3, 2
a3 , 2

a3 , 2
a3 , 2

a3 , 2

A1
a1,1
a1, 2
a1,3
a1, 4
a1, 5
a1, 6
a1, 7
a1,8

y A3

7 a3,1
5 a3,1

8 a3,1

12 a3, 2
8 a3 , 2

14 a3, 2
12 a3, 2

19 a3, 2

A1
a1,1
a1, 2
a1, 3
a1, 4
a1,5
a1,6
a1, 7
a1,8

z = RunningSum(y )

12

20

12

20

34

46

65

Notice, in the above example the function z = f(y) =


RunningSum(y) looks like an aggregation function at the first
place, since the correct mathematical formula for that
function can be written as:
k

z k = yi
i =1

This function takes several values of variable y and returns a


number. However, note that vectors y and z have the same
size since there is no reduction in the cardinality, that is, no
group-by is done. This is similar to the characteristic of
single-value functions, but there is another characteristic of a
relative function that differentiates itself from a single-value
function: the computation is dependent on how the vector is
sorted and when to start computation again.
For more information on functions, see the text under
Terminology and notation conventions, section of this
chapter.

2003 MicroStrategy, Inc.

Metric formulae

Overview

MicroStrategy Analytical Functions Reference

Function Parameters
Function parameters are parameters that help functions
determine how to perform the computation. All
operators/functions have one or more function parameters.
And these function parameters have their own individual
settings. Thus, given the same input, two functions with
different function parameters will have different outputs as
the result of the computation. On the other hand, two
functions with different settings will behave differently.
For example, an aggregation operator/function Count has
one function parameter with three settings: Distinct, FactID
and Null in a tab that is called <FP>, where <FP> represents
the only Count Parameter tab. The settings have their default
values (true, false, NULL, and so on) and can be modified as
required. On the other hand, any OLAP functions, such as:
RunningSum, RunningAvg, MovingSum, and so on have
more than one function parameter tabs. They have: <FP>,
<BB>, and <SB> tabs, where <FP>, <BB> and <SB> stand
for Function Parameters, Break-By, and Sort-By respectively.
These tabs are called Function Parameters and they appear
right after the name of the operator/function.
Referring to Example 8 from the Functions section, the
function can be completely represented as:
z = RunningSum < > < A3> <A1> (y)
This indicates that the function is computed as the running
sum of variable y (which should be a metric), but the
computation will start over for every member of attribute A3
(Break-By A3), and it is sorted according to the elements of
attribute A1 in ascending order (Sort-By A1 ascending).
z = RunningSum < Break-By= A3; Sort-By= A1> (y)
For example, if you wanted to calculate the moving average
(MovingAvg) of the Stock Price for three days, you would
compute the value of the Stock Price by performing a
Break-By on Stock ID and Sort-By on Day.

10 Metric formulae

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

All functions have at least one <FP> tab. However, most


functions do not have specific settings that need to be set.
Thus to make it simpler, unless we really need to set specific
parameters, we will remove the window from our notation.

Terminology and notation in metric functions


The following notation conventions and associated terms are
applied throughout this document:

A vector is an array of values corresponding to a given


attribute. The following conditions apply to vectors in the
context of MicroStrategy 7i metrics:
Values in a vector correspond to a column in a fact
table.
A vector is usually represented as X or [X].
When multiple vectors or value arrays are involved in
a metric calculation, they are identified as X1, X2, X3,
and so on.
An array of values can serve either as input to the
calculation of a metric, or (in the case of simple or
nested metrics) as the metric output or return value.

A function is commonly expressed as f (x) = y, where


x represents any value in the input set of values X, also
called the independent value set for the function.
f represents the operator applied to each input value
x.
y represents one or more values in the output or
return, also called the dependent value set for the
function.

2003 MicroStrategy, Inc.

Metric formulae

11

Overview

MicroStrategy Analytical Functions Reference

A fact name can be written either as a continuous string


or as two or more words (either as Total_Dollar_ Sales or
[Total Dollar Sales], for example). The following applies
to the associated notation:1
If the fact name is written as a continuous string, it can
be entered within simple parentheses in a metric
formula (for example, (Total_Dollar_Sales)).
If the fact name consists of two or more separate
words, it should be enclosed in brackets, within
parentheses, in a metric formula (for example, ([Total
Dollar Sales])).

The Intelligence Server interprets each discrete character string as a single entity;
square brackets are necessary to identify multiple-word content as one fact.

Facts and simple metrics have very similar notations in


metric definition. Differences between the two are as
follows:
A fact is enclosed in parentheses and includes only its
own value: (Fact).
As is the case with a fact, a metric is enclosed in
parentheses, but, in addition to its value, also includes
a level of aggregation in its notation: Sum(Fact) {~+}
(see Level of aggregation (dimensionality) under
Metric notation and syntax, below).

Metric notation and syntax


General
Conventional notation for metric syntax is as follows:
f u n c t io n

fa c t

f ilt e r

A g g r e g a tio n F u n c tio n < F P > ( F a c t) { e ~ + } < F L > |T R |


f u n c t io n
p a ra m e te r

12 Metric formulae

a g g r e g a t io n
le v e l

t r a n s f o r m a t io n

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

In the in the metric syntax diagram,

AggregationFunction is the name of the function being


used

<FP> is a function parameter (see description below)

(FACT) corresponds to a specific column in a fact table

{e~+} denotes the metric aggregation level (see


description below)

<FL> is the filter applied to the metric

|TR| denotes a transformation

An example
In the metric AvgDev < > ([Total Dollar Sales]) {~+,
Region+}, definition details are as follows:

the function applied is Average Deviation (AvgDev)

there are no parameters specified

the fact table column supplying the data is [Total Dollar


Sales]

the metric is calculated at the Region level

the filter is empty

there is no transformation performed

The information that follows includes identification and


descriptions of these metric components.

2003 MicroStrategy, Inc.

Metric formulae

13

Overview

MicroStrategy Analytical Functions Reference

Attributes and attribute elements


In the context of MicroStrategy 7i metric syntax:
Attributes are represented by a name that begins with an
upper-case letter (Store, Customer, Item). If an alias is used
to represent an attribute, that alias is given by an upper-case
letter (A, B, C); if a hierarchical relationship is used, the alias
is followed by a numerical subscript that indicates a
parent-child relationship (in a given hierarchy, A1 is the
parent of A2; A3 is a child of A2).
When aliases are used to represent attribute elements, those
aliases are displayed in lower-case letters that match the
attribute alias (attribute A may have attribute elements a1, a2,
a3). If the attribute alias includes a subscript to denote
hierarchical order, attribute element aliases reflect that as
well: attribute A2 may have elements a2,1, a2,2, a2,3 (for
example, Store may have aliases store1, store2, and store3).

Level of aggregation (dimensionality)


Used to calculate simple metrics, the level of aggregation is
represented in metric syntax within curly brackets ({ }). The
following applies to the use of aggregation-level data:

14 Metric formulae

Aggregation levels can be denoted as any one of the


following: {~+, !, An, +}.

The default aggregation level notation is ~, which


denotes report-level dimensionality. To indicate
aggregation at a given attribute level, either the attribute
itself or that attributes alias is added to the default: to
show aggregation at the level of attribute A3, the notation
is {~, A3} (for example, to aggregate at the Customer level,
the aggregations is expressed as {~, Customer}.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

In general, an aggregation level has a prefix, which can be


either e or !, and a suffix, which can be +, *, %, or e. The
following applies to the use of aggregation-level symbols:
e, either as a prefix or as a suffix, is used to denote an
empty value, and is not displayed on the interface
window
! is used as an attribute prefix, and denotes none or
ignore
+, *, and % are used as attribute suffixes, and stand for
standard, absolute and ignore respectively

Filters
The following applies to the use of filter notation in metric
syntax:

A filter is generally shown as <FL>, where FL is the filter


name.

< > denotes an empty filter.

The filter applied is always shown as part of the syntax,


even when it is empty.

Filters can be used in reports, in metrics, or in both. When


filters exist in both a metric and a report, the metrics level of
aggregation, also known as metric dimensionality, plays an
important role in the way in which the Intelligence Server
interprets those filters.

Transformations
Transformations are created through the addition of
relationship tables in the warehouse, and denoted in syntax
as |TR|, where TR is the name of the transformation.

2003 MicroStrategy, Inc.

Metric formulae

15

Overview

MicroStrategy Analytical Functions Reference

The MicroStrategy 7i engine


Structure
The MicroStrategy 7i Intelligence Server has an engine
component. This engine component comprises of the
following:

The SQL Engine, which generates the SQL and associated


logic for functions performed by the database, and
communicates with the Analytical Engine as necessary.

The Query Engine, which carries out the instructions


issued by the SQL Engine.

The Analytical Engine, which performs:


multi-dimensional storage
data representation and manipulation
advanced analytical processing
back-end integration

Functions
Functions supported by the Intelligence Server can be of
three types:
those that can be handled only by the Analytical
Engine (such as finance functions)
those that can be handled only by the database (such
as date-and-time functions)
those that can be handled either by the Analytical
Engine or by the database

16 The MicroStrategy 7i engine

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

of MicroStrategy 7i functions that are not


* Handling
exclusive to one engine is contingent upon database

capability: if the database can perform the calculation,


the SQL Engine sends the necessary instructionsthat
is, the associated syntax valuesto the database;
otherwise, the Analytical Engine takes over the task.

a database platform does not support a given


+ Iffunction
of the database-only type, that function
cannot be calculated.

How Intelligence Server uses functions


There are two types of analytical functions:

Group-value functions. Examples include: Avg, AvgDev,


Correlation, Count, HomoscedasticTTest, Intercept,
Slope, StDev, Sum, and so on.

Single-value functions. Examples include: Abs, Accrint,


Ddb, Cos, Ln, Round, Truncate, and so on.

We will also discuss OLAP functions towards the end.

Relative Functions. Examples include: Rank,


RunningSum, MovingAvg, and so on

Using Group-value function.


There are three usages of group-value functions. They can be
used to create the following:

2003 MicroStrategy, Inc.

Simple metric

Simple metric where formula is based on metrics

New subtotal

How Intelligence Server uses functions

17

Overview

MicroStrategy Analytical Functions Reference

Creating a simple metric (or its variation where the formula is


based on metrics) is similar in the sense that the group-value
function is used to group a vector(s) into scalar. The only
difference is that the former takes a fact as an input, while the
latter takes another simple/compound metric as its input.
The creation of a new subtotal can be achieved through the
MicroStrategy Desktop interface with the Subtotal Editor or
through the SDK. We will briefly mention this towards the
end.
A simple metric can be written (by default) as:
Group-valueFunction<FP>([Fact]) { e~+}<FL>|TR|
Since e indicates NULL, and is not displayed through the
MicroStrategy Desktop interface, the function is displayed as
the following when we open a metric in the Metric Editor):
Group-valueFunction<FP>([Fact]) {~+}<FL>|TR|
Basically, we can replace Group-valueFunction with any
regular group-value functions (such as: Sum, Avg, Max, Min,
Count) or any other group-value functions from Appendix A
(such as: AvgDev, Skew, MeanTTest, Npv, Irr, and so on.
That is, all functions that end with notations {~+}<FL>|TR|).
Examples of simple metrics with their notations are shown
below:

Sum([Revenue]) {~+}

AvgDev([Revenue]) {~+, Category+}

Correlation([Revenue], [Freight]) {~+}

From the discussion above, we can conclude that a simple


metric is a metric that is defined using any group-value
function on top of some facts or variations of those facts. In
general, any kind of metric must have at least one
group-value function. Note that Correlation([Revenue],
[Freight]) {~+} is a split metric since it uses two facts as
inputs.
The following example explains what is meant by variation
facts:

18 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

We can easily apply a simple function at the top of a fact, and


it would still remain a fact. For example,
Sum(Ln([Revenue])) {~+} is a valid simple metric. Notice
that in this case Ln([Revenue]) is still a fact, since the
function Ln just transforms the fact [Revenue] into another
form. This is what is meant by variation of facts.
Note that the computation of grouping functions is not done
by the database. It is done by the Intelligence Server instead.
Refer to the following examples to understand the difference
between SQL (database) and non-SQL (Intelligence Server)
group-value functions and to get familiarized with how
MicroStrategy 7i does the computations.
Example 1:
Consider a simple report (Report 01.a) where we put an
attribute Region on row axis and a simple metric that is
defined as M01.a = Sum([Dollar Sales]) {~+} on column
axis. This report shows the sales for each country. The SQL
for this particular report will look like the following:
Report 01.a (SQL Group-value function)
select
a13.REGION_ID REGION_ID,
max(a14.REGION_NAME) REGION_NAME,
sum(a11.ORDER_AMT) M01ASUMDLRSL
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 (a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)
group by
a13.REGION ID

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

19

Overview

MicroStrategy Analytical Functions Reference

Now, consider a similar report (Report 01.b), again with the


same attribute (Region) on row axis, but with a different
simple metric defined as M01.b = AvgDev([Dollar Sales])
{~+} on column axis. This report shows how sales data varies
from its mean for each country. The SQL for this report will
be:
Report 01.b (Intelligence Server
Group-value function)
select
a11.ORDER_DATE DATE_ID,
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 (a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)
[An analytical SQL]

The fact table, ORDER_FACT, has 3 columns that make up


the primary key, namely: ORDER_DATE, EMP_ID, and
ORDER_ID.
In this second report (Report 01.b), Intelligence Server
performs the following steps:

It brings back all fact data (rows) in the ORDER_FACT


table from the warehouse (it selects all primary keys from
the fact table with no aggregation function in front of the
[ORDER_AMT] column).

It uses the result set (that is held in memory) to compute


the metric, namely: AvgDev([ORDER_AMT]) {~+} for
each store (Note the term [An analytical SQL] in the above
report).

It displays the final result.

To get a better understanding of what is happening when a


metric with Intelligence Server group-value function is
computed, the background computational process is
discussed below.

20 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

In the previous example, the dimensionality of all metrics is


defined as {~+} (this is equivalent to {e~+} notation since we
do not see any prefix dimensionality in front of ~) which is
basically the default level. The notation ~ means that both
metrics are calculated at the report level. In the above
reports, they are calculated at Country level since they have
the attribute Country on the report.
Let us consider another example to understand how the
Intelligence Server works.
Example 2:
We still use the same example as in Example 1. However, now
we add a dimensionality to each metric for comparison: we
use Sum([Dollar Sales]) {~+, Country+} for the Report
02.a and AvgDev([Dollar Sales]) {~+, Country+} as the
metric in Report 02.b. Note that attribute Country is a parent
of Region, and the relationship is one to many. The SQL
statements for both reports are shown.
Report 02.a (SQL Group-value function)
create table ZZCN0VG100 (
COUNTRY_ID INTEGER,
M02ASUMDLRSL
DOUBLE)
partitioning key (COUNTRY_ID)
insert into ZZCN0VG100
select
a12.COUNTRY_ID COUNTRY_ID,
sum(a11.ORDER_AMT) M02ASUMDLRSL
from
ORDER_FACT a11
join LU_EMPLOYEE
a12
on (a11.EMP_ID = a12.EMP_ID)
group by
a12.COUNTRY_ID
select

distinct a11.REGION_ID REGION_ID,


a11.REGION_NAME REGION_NAME,
p1.M02ASUMDLRSL M02ASUMDLRSL
from
ZZCN0VG100 p1
join LU_REGION a11
on (p1.COUNTRY_ID = a11.COUNTRY_ID)
drop table ZZCN0VG100

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

21

Overview

MicroStrategy Analytical Functions Reference

The first two passes of SQL are done to compute the metric at
the appropriate level (namely at Country level), while the
third pass is done to join with attribute Region since the
result of aggregation has to be displayed for each region. This
example is built using DB2 UDB version 5.2 as the
warehouse. Moreover, for the above report, the VLDB for
Intermediate Table type is set to Permanent Table.
Report 02.b (MSTR Engine group-value function)
select
a11.ORDER_ID ORDER_ID,
a11.EMP_ID EMP_ID,
a11.ORDER_DATE DATE_ID,
a12.COUNTRY_ID COUNTRY_ID,
a11.ORDER_AMT WJXBFS1
from
ORDER_FACT a11
join LU_EMPLOYEE
a12
on (a11.EMP_ID = a12.EMP_ID)
create table ZZCN0VHT00 (
COUNTRY_ID INTEGER,
WJXBFS1
DOUBLE)
partitioning key (COUNTRY_ID)
[An analytical SQL]
insert into ZZCN0VHT00 values (1, 156.421081413)
[The rest of the INSERT statements have been
omitted from display].
select

distinct a11.REGION_ID REGION_ID,


a11.REGION_NAME REGION_NAME,
p1.WJXBFS1 M02BAVGDEVDL
from
ZZCN0VHT00 p1
join LU_REGION a11
on (p1.COUNTRY_ID = a11.COUNTRY_ID)
drop table ZZCN0VHT00

Now, notice how the first two-pass SQL in Report 02.a is


replaced by a four-pass SQL (including [An analytical SQL])
in Report 02.b to compute AvgDev (since this operator is not
a database group-value function). The last pass is the same
since it is done just to display the result for all regions.

22 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Using group-value function in subtotal


This functionality can be achieved through the Subtotal
Editor in the MicroStrategy Desktop interface and the SDK. It
is briefly discussed here.
The MicroStrategy Desktop interface has the following
system subtotals: Total (Sum), Count, Average, Minimum,
Maximum, Product, Median, Mode, Standard Deviation,
Variance, and Geometric Mean. These are called system
subtotals since they are predefined for all metrics. These
subtotals are seen in the Subtotals/Aggregations tab when
you open a metric using the Metric Editor.
These system subtotals are built using group-value functions.
For example, Total is predefined as as Sum([DSS Me
Node]) where [DSS Me Node] is just a place holder for any
metric (that is, it can be replaced by any metric). Similarly,
Standard Deviation is predefined as StDev([DSS Me
Node]). With the Subtotal Editor or the SDK, you can build
more subtotals using our group-value functions (AvgDev,
Correlation, RSquare, NPV, IRR, and so on). These new
user-defined subtotals can be used for any metric.

Using Single-value function


There are three usages of single-value functions as mentioned
below:

2003 MicroStrategy, Inc.

to transform a fact into another fact before group-value


function

to create a compound metric (to apply after group-value


function)

to create a consolidation element

How Intelligence Server uses functions

23

Overview

MicroStrategy Analytical Functions Reference

Transforming a fact into another fact or creating a compound


metric involves building metrics. They are similar in the
sense that the single-value function is used to transform one
or more vectors into another vector. The only difference is
that the first usage (transforming fact) must be used before a
group-value function, while compound metric creation uses
single-value function after the group-value function. The
creation of a consolidation element can only be achieved
through SDK. We will briefly mention this towards the end.
Transforming a fact into another fact
Consider the following valid simple metric definitions:

Sum(Ln([Revenue])) {~+}

Sum(Trunc([Revenue])) {~+}

In this case, the fact [Revenue] will be transformed into


another fact, namely: [Ln([Revenue])] or
[Trunc([Revenue])].
The following example describes this type of usage and
displays the SQL that is generated.
Example 1:
Consider the two metrics displayed above: M03.a =
Sum(Ln([Dollar Sales])) {~+} and M03.b =
Sum(Trunc([Dollar Sales])) {~+}. If we put [M03.a] with
Region on the template, here is the SQL that is generated.
Report 03.a (SQL Single-value
before Group-value functions)
select
from
join
on
join
on
join
on
group by

24 How Intelligence Server uses functions

a13.REGION_ID REGION_ID,
max(a14.REGION_NAME) REGION_NAME,
Sum(Ln(a11.ORDER_AMT)) M03ASUMLNDLR
ORDER_FACT a11
LU_EMPLOYEE
a12
(a11.EMP_ID = a12.EMP_ID)
LU_CALL_CTR
a13
(a12.CALL_CTR_ID = a13.CALL_CTR_ID)
LU_REGION a14
(a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)
a13.REGION_ID

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Notice that the Ln function is done over the fact [Dollar


Sales] (that is defined by column [ORDER_AMT] in the
warehouse) first, and then the Sum function is performed on
the top of the new fact, namely: [Ln([Dollar Sales])]. It is
also imperative to note that all computations are done by the
database (via SQL) since the warehouse that we use, supports
Ln function.
However, if we put the other metric, namely [M03.b] with
Region on the template, then the following SQL will be
generated.
Report 03.b (MSTR Engine Single-value
before Group-value functions)
select

from
join
on
join
on
join
on

a11.ORDER_DATE DATE_ID,
a11.EMP_ID EMP_ID,
a11.ORDER_ID ORDER_ID,
a13.REGION_ID REGION_ID,
a14.REGION_NAME REGION_NAME,
a11.ORDER_AMT WJXBFS1
ORDER_FACT a11
LU_EMPLOYEE
a12
(a11.EMP_ID = a12.EMP_ID)
LU_CALL_CTR
a13
(a12.CALL_CTR_ID = a13.CALL_CTR_ID)
LU_REGION a14
(a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)

[An analytical SQL]

Note that in this case the functions Trunc and Sum are
computed by the Intelligence Server. It computes the new fact
[Trunc([Dollar Sales])] first, and then uses the Sum
function for summing over the new fact for each region.
The second usage of single-value function (as compound
metric) is simple. Subtraction, addition, division, and
multiplication operators (, +, /, *) are common examples of
single-value functions. Here are some examples:
[Sum([Dollar Sales]) {~+}] / [Sum([Dollar Sales]) {~+,
Country+}]
[Sum([Dollar Sales]) {~+}] + [Sum([Freight]) {~+}]
Consider the following metric definitions:
2003 MicroStrategy, Inc.

How Intelligence Server uses functions

25

Overview

MicroStrategy Analytical Functions Reference

M04.a = Ln([Sum([Dollar Sales]) {~+}])

M04.b = Trunc([Sum([Dollar Sales]) {~+}])

If we put [M03.a] and [M04.a] together with attribute Region


on the template (From Example 1 above, M03.a is defined as:
Sum(Ln([Dollar Sales])) {~+}), the following SQL will be
generated.
Report 04.a (SQL Single-value before
and after Group-value functions)
select

from
join
on
join
on
join
on
group by

a13.REGION_ID REGION_ID,
Max(a14.REGION_NAME) REGION_NAME,
Sum(Ln(a11.ORDER_AMT)) M03ASUMLNDLR,
Ln(Sum(a11.ORDER_AMT)) WJXBFS1
ORDER_FACT a11
LU_EMPLOYEE
a12
(a11.EMP_ID = a12.EMP_ID)
LU_CALL_CTR
a13
(a12.CALL_CTR_ID = a13.CALL_CTR_ID)
LU_REGION a14
(a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)
a13.REGION_ID

Similarly, if we put [M03.b] and [M04.b] together with


attribute Region on the template, then the SQL will be as
follows.
Report 04.b (MSTR Engine Single-value
before and after Group-value functions)
select
a11.ORDER_DATE DATE_ID,
a11.EMP_ID EMP_ID,
a11.ORDER_ID ORDER_ID,
a13.REGION_ID REGION_ID,
a14.REGION_NAME REGION_NAME,
a11.ORDER_AMT WJXBFS1,
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 (a12.COUNTRY_ID = a14.COUNTRY_ID and
a13.REGION_ID = a14.REGION_ID)
[An analytical SQL]

26 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Notice that fact that is called [Dollar Sales] (i.e., column


[ORDER_AMT] in the ORDER_FACT table) is brought back
twice. The first one (WJXBFS1) is used to compute [M03.a],
namely: truncating [ORDER_AMT] first, and then summing
over the result. The second one (WJXBFS2) is used to
compute [M04.a], namely: summing column
[ORDER_AMT] first, and then truncating the result. All
computations are done by the Intelligence Server.
Note that all single-value functions are similar to operators
like: , +, /, or *.
Using single-value function in consolidation
This functionality can only be achieved through SDK. It is
briefly discussed here.
Consolidations allow calculations between consolidation
elements (CE). An example of consolidation will look like:

CE01 = {Region = North-East}

CE02 = {Region = Mid-Atlantic}

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

Where CEs are consolidation elements. Notice the usage of


the division operator (that is, /) in the third consolidation
element, CE03. SDK allows various definitions for a
consolidation with the following consolidation elements:

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

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

CE06 = Abs({CE04} {CE05})

Using relative functions


We can understand how Intelligence Server computes
relative functions by discussing examples for relative
functions based on the following properties:

2003 MicroStrategy, Inc.

Window size

Break-by tab

How Intelligence Server uses functions

27

Overview

MicroStrategy Analytical Functions Reference

Sort-by tab

NULL handling

Tie handling

We will compare SQL syntax when warehouse database


supports ANSI OLAP functions (DB2 UDB 7) versus SQL
syntax when Analytical Engine performs computation (DB2
UDB 5.2).
WindowSize in Moving Functions
Example 1:
Create a metric [M01], that is defined as Sum([Dollar
Sales]) {~+}. Then create an OLAP metric called [OM01],
that is defined via the Metric Editor as: MovingAvg<BB =
{[Promotion Type]}><SB = Value>([M01], 5).
[OM01] = MovingAvg<BB = {[Promotion Type]}><SB =
Value asc>([M01], 5)
Notice that the OLAP metric [OM01] basically computes
moving average of [M01] with a window size of 5. The OLAP
metric will have to be computed after it is sorted by the value
of [M01] in ascending order. Moreover, the computation will
start over for every [Promotion Type].

28 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

If we put two attributes {[Promotion Type], Item} on the Row


axis and we put the above metrics on the Column axis, and
run this report with an empty filter against a database that
does not support OLAP functions (such as DB2 UDB 5.2), the
following SQL is generated:
Report 01.a (Analytical Engine OLAP)
select
a12.PROMO_TYPE_ID PROMO_TYPE_ID,
max(a14.PROMO_TYPE_DESC)
PROMO_TYPE_DESC,
a11.ITEM_ID ITEM_ID,
max(a13.ITEM_NAME) ITEM_NAME,
sum((a11.QTY_SOLD * (
a11.UNIT_PRICE - a11.DISCOUNT))
) M01SUMDLRSLS,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT))
) WJXBFS1
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on (a11.PROMOTION_ID =
a12.PROMO_SALE_ID)
join LU_ITEM
a13
on (a11.ITEM_ID = a13.ITEM_ID)
join LU_PROMO_TYPE
a14
on (a12.PROMO_TYPE_ID =
a14.PROMO_TYPE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID
[An analytical SQL]

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

29

Overview

MicroStrategy Analytical Functions Reference

However, if the above report is executed against a warehouse


database that supports OLAP computations (such as DB2
UDB 7), then we the following SQL will be generated.
Report 01.b (DB2 UDB 7 OLAP)
select
a12.PROMO_TYPE_ID PROMO_TYPE_ID,
max(a14.PROMO_TYPE_DESC)
PROMO_TYPE_DESC,
a11.ITEM_ID ITEM_ID,
max(a13.ITEM_NAME) ITEM_NAME,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
M01SUMDLRSLS,
avg(sum((a11.QTY_SOLD*a11.UNIT_PRICE a11.DISCOUNT))))
over(partition by a12.PROMO_TYPE_ID
order by sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
asc rows 4 preceding) WJXBFS1
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on (a11.PROMOTION_ID = a12.PROMO_SALE_ID)
join LU_ITEM
a13
on (a11.ITEM_ID = a13.ITEM_ID)
join LU_PROMO_TYPE
a14
on (a12.PROMO_TYPE_ID = a14.PROMO_TYPE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID

From the above example (Example 1), due to the database


syntax, a window size of 5 is converted to: rows 4 preceding.
This gives an idea that the concept of window size in
Intelligence Server includes the current row, while database
consider the window size as previous (preceding) rows.
We can see how the Intelligence Server computes OLAP
functions when the database does not support ANSI OLAP
functions. The Intelligence Server brings back all components
(that is, input metric, break-by and sort-by parameters). In
the above examples, since <SB> parameter is by Value, then
it is sufficient to bring back just the input metric (WJXBFS1).
Break-by in OLAP Functions
In the Intelligence Server, <BB> is only available at the
attribute level. In other words, we can start over certain
computations of OLAP functions when a part of the metric
belongs to a different attribute element.

30 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

In the example before, we have an OLAP function that has


[Promotion Type] in <BB> window. Notice that Intelligence
Server will have to select this attribute (in select clause) if
OLAP function is computed by Analytical Engine. If the
warehouse database can compute OLAP function, then this
attribute has to be in the select clause, as well as in the
partition by clause.
Any kind of attribute in <BB> window of an OLAP metric will
always be applied (meaning that it is always in the select
clause as well as in the partition by clause), regardless of
whether the attribute is on the template or not.
Example 2:
Suppose you run a report similar to the one in Example 1, but
delete the attribute {[Promotion Type]} from the template.
Metric [M01] = Sum([Dollar Sales]){~+} will be
completely different from the previous report because
{[Promotion Type]} is basically a parent of a quality
attribute, namely: {Promotion}. Notice that the two
attributes {Item, Quarter} together define {Promotion}.
Therefore, if we do not have {[Promotion Type]} on the
template (that is, only attribute {Item} on the template), then
the level of aggregation for metric [M01], that is, {~+}, will
be replaced by {Item}.
On the other hand, OLAP metric [OM01] will have to be
broken by for each [Promotion Type]. This <BB> is very
similar to having group-by level. Hence, metrics [M01] and
[OM01], that are on the template, will have to be resolved in
different passes.

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

31

Overview

MicroStrategy Analytical Functions Reference

For a database that does not support OLAP function (such as


DB2 UDB 5.2), the following SQL will be generated.
Report 02.a (Analytical Engine OLAP)
Pass #01
create table ZZCN04GM00 (
ITEM_ID
INTEGER,
M01SUMDLRSLS
DOUBLE)
partitioning key (ITEM_ID)
insert into ZZCN04GM00
select
a11.ITEM_ID ITEM_ID,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
M01SUMDLRSLS
from
ORDER_DETAIL
a11
group by
a11.ITEM_ID
Pass #02
select

a12.PROMO_TYPE_ID PROMO_TYPE_ID,
a11.ITEM_ID ITEM_ID,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
WJXBFS1
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on a11.PROMOTION_ID = a12.PROMO_SALE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID
create table ZZCN04GM01 (
PROMO_TYPE_ID
INTEGER,
ITEM_ID
INTEGER,
WJXBFS1
DOUBLE)
partitioning key (PROMO_TYPE_ID, ITEM_ID)
[An analytical SQL]
insert into
ZZCN04GM01 values (1, 2, 10.3333333333333)
[The rest of the INSERT statements have been
omitted from display].
Pass #03
select

from
join
on
join
on

distinct pa2.ITEM_ID ITEM_ID,


a11.ITEM_NAME ITEM_NAME,
pa1.M01SUMDLRSLS M01SUMDLRSLS,
pa2.WJXBFS1 WJXBFS1
ZZCN04GM01 pa2
ZZCN04GM00 pa1
(pa2.ITEM_ID = pa1.ITEM_ID)
LU_ITEM
a11
(pa2.ITEM_ID = a11.ITEM_ID)

drop table ZZCN04GM00


drop table ZZCN04GM01

32 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

If the database supports computation of OLAP functions


(such as DB2 UDB 7), then the following SQL will be issued.
Report 02.b (DB2 UDB 7 OLAP)
Pass #01
create table ZZCN057C00 (
ITEM_ID
INTEGER,
M01SUMDLRSLS
DOUBLE)
insert into ZZCN057C00
select
a11.ITEM_ID ITEM_ID,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
M01SUMDLRSLS
from
ORDER_DETAIL
a11
group by
a11.ITEM_ID
Pass #02
create table ZZCN057C01 (
PROMO_TYPE_ID
INTEGER,
ITEM_ID
INTEGER,
WJXBFS1
DOUBLE)
insert into ZZCN057C01
select
a12.PROMO_TYPE_ID PROMO_TYPE_ID,
a11.ITEM_ID ITEM_ID,
avg(sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT))))
over(partition by a12.PROMO_TYPE_ID
order by sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
asc rows 4 preceding) WJXBFS1
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on (a11.PROMOTION_ID = a12.PROMO_SALE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID
Pass #03
select

from
join
on
join
on

distinct pa2.ITEM_ID ITEM_ID,


a11.ITEM_NAME ITEM_NAME,
pa1.M01SUMDLRSLS M01SUMDLRSLS,
pa2.WJXBFS1 WJXBFS1
ZZCN057C01 pa2
ZZCN057C00 pa1
(pa2.ITEM_ID = pa1.ITEM_ID)
LU_ITEM
a11
(pa2.ITEM_ID = a11.ITEM_ID)

drop table ZZCN057C00


drop table ZZCN057C01

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

33

Overview

MicroStrategy Analytical Functions Reference

Notice that in both the SQLs above, the Intelligence Server


will always select {[Promotion Type]} in Pass #02 even
though {[Promotion Type]} is not on the template. By doing
this, Intelligence Server makes sure that it will be consistent
with the level of aggregation.
Sort-by in OLAP Functions
For OLAP functions, sorting is done before computation is
performed. Basically, there are 2 choices for <SB> window:
<Sort by Value in Subexpression> Reports 01 and 02
above give examples of this type. Note that if warehouse
database can perform computation of OLAP functions, then
the same definition of subexpression ([M01] is defined as
Sum([Dollar Sales]){~+}) will appear in order by clause.
For example, in the above reports we have: order by
sum((a11.QTY_SOLD * (a11.UNIT_PRICE - a11.DISCOUNT))) asc
to represent the <SB = Value ascending> window.
<Sort by Objects> Let us classify the <SB Oject> into two
major objects: <SB Object = Attribute> and <SB Object =
Metric>.
Consider the following example where an OLAP metric is
sorted by a normal attribute (either by ID or Desc).
Example 3:
Create an OLAP metric that is defined as:
[OM04a] = RunningSum<BB = {[Customer Region]}><SB
= ([Customer City]@ID asc, Customer@Name dsc)>([M01])
Then add attributes {[Customer Region], Customer} and
[OM04a] on template.
Notice that [OM04] is sorted by [Customer City]@ID in
ascending order, then by Customer@Name in descending
order, while there is no attribute [Customer City] on the
template. We assume that attribute Customer is child of a
normal attribute [Customer City], and [Customer City] is a
child of [Customer Region].

34 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

For a database that does not support OLAP functions (such as


DB2 UDB 5.2), the following SQL will be generated.
Report 04.a.1 (Analytical Engine OLAP)
select
a14.CUST_REGION_ID CUST_REGION_ID,
max(a15.CUST_REGION_NAME)
CUST_REGION_NAME,
a12.CUSTOMER_ID CUSTOMER_ID,
max(a13.CUST_LAST_NAME)
CUST_LAST_NAME,
max(a13.CUST_FIRST_NAME)
CUST_FIRST_NAME,
a13.CUST_CITY_ID CUST_CITY_ID,
sum(a11.ORDER_AMT) WJXBFS1
from
ORDER_FACT a11
join LU_ORDER
a12
on (a11.ORDER_ID = a12.ORDER_ID)
join LU_CUSTOMER
a13
on (a12.CUSTOMER_ID = a13.CUSTOMER_ID)
join LU_CUST_CITY
a14
on (a13.CUST_CITY_ID = a14.CUST_CITY_ID)
join LU_CUST_REGION a15
on (a14.CUST_REGION_ID =
a15.CUST_REGION_ID)
group by
a14.CUST_REGION_ID,
a12.CUSTOMER_ID,
a13.CUST_CITY_ID
[An analytical SQL]

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

35

Overview

MicroStrategy Analytical Functions Reference

If the database supports computation of OLAP functions


(such as DB2 UDB 7), then the following SQL will be issued.
Report 04.b.1 (DB2 UDB 7 OLAP)
select
a14.CUST_REGION_ID CUST_REGION_ID,
a15.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
a14.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
join LU_ORDER
a12
on (a11.ORDER_ID = a12.ORDER_ID)
join LU_CUSTOMER
a13
on (a12.CUSTOMER_ID = a13.CUSTOMER_ID)
join LU_CUST_CITY
a14
on (a13.CUST_CITY_ID = a14.CUST_CITY_ID)
join LU_CUST_REGION a15
on (a14.CUST_REGION_ID =
a15.CUST_REGION_ID)
group by
a14.CUST_REGION_ID,
a15.CUST_REGION_NAME,
a12.CUSTOMER_ID,
a13.CUST_LAST_NAME,
a13.CUST_FIRST_NAME,
a13.CUST_CITY_ID

Notice in both SQLs, the Intelligence Server always selects


a13.CUST_CITY_ID, even though attribute [Cutomer City]
is not on the report. Moreover, in Report 04.b.1, this attribute
is also in the (group-by) clause. Sort by attribute [Customer
City]@ID is done because of attribute Cutomer which is a
child of [Customer City].
Note that in the Report 04.b.1 above, the SQL has to issue
group-by CUST_LAST_NAME and CUST_FIRST_NAME
since we need to sort by Customer@Name. For optimization
purposes, the Intelligence Server will only group by the ID
column. However, there is a VLDB setting that allows you to
group-by non-ID columns. This VLDB setting can be set for
every single report that uses an OLAP metric with a sort-by
attribute description.

36 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Consider the following example where an OLAP metric is


sorted by a quality attribute (either by ID or Desc).
Example 4:
Create an OLAP metric that is defined as:
[OM05] = RunningAvg<BB = {[Promotion Type]}><SB =
(Promotion@Desc asc, [M01] asc)>([M01])
Then add attributes {[Promotion Type], Item} and [OM05]
on template. Notice that this OLAP metric [OM05] is sorted
by quality attribute: Promotion, and then by metric [M01].
For this example, also note that attribute Item which is a
child of attribute Promotion is also on the template. If we do
not know that attribute Promotion is a quality attribute, then
we may expect that metric [OM05] to be sorted by the
attribute Promotion. However, this is not the case since
attribute Promotion is actually a quality since it has 2
children: attributes Item and Quarter.
For databases that do not support OLAP functions (such as
DB2 UDB 5.2), the following SQL will be generated.
Report 05.a (Analytical Engine OLAP)
select
a12.PROMO_TYPE_ID PROMO_TYPE_ID,
max(a14.PROMO_TYPE_DESC)
PROMO_TYPE_DESC,
a11.ITEM_ID ITEM_ID,
max(a13.ITEM_NAME) ITEM_NAME,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
WJXBFS1,
sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
WJXBFS2
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on (a11.PROMOTION_ID = a12.PROMO_SALE_ID)
join LU_ITEM
a13
on (a11.ITEM_ID = a13.ITEM_ID)
join LU_PROMO_TYPE
a14
on (a12.PROMO_TYPE_ID =
a14.PROMO_TYPE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID
[An analytical SQL]

2003 MicroStrategy, Inc.

How Intelligence Server uses functions

37

Overview

MicroStrategy Analytical Functions Reference

If the database supports computation of OLAP functions


(such as DB2 UDB 7), then the following SQL will be issued.
Report 05.b (DB2 UDB 7 OLAP)
select
a12.PROMO_TYPE_ID PROMO_TYPE_ID,
max(a14.PROMO_TYPE_DESC)
PROMO_TYPE_DESC,
a11.ITEM_ID ITEM_ID,
max(a13.ITEM_NAME) ITEM_NAME,
avg(sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT))))
over(partition by a12.PROMO_TYPE_ID
order by sum((a11.QTY_SOLD *
(a11.UNIT_PRICE - a11.DISCOUNT)))
asc rows unbounded preceding)
WJXBFS1
from
ORDER_DETAIL
a11
join LU_PROMOTION
a12
on (a11.PROMOTION_ID =
a12.PROMO_SALE_ID)
join LU_ITEM
a13
on (a11.ITEM_ID = a13.ITEM_ID)
join LU_PROMO_TYPE
a14
on (a12.PROMO_TYPE_ID =
a14.PROMO_TYPE_ID)
group by
a12.PROMO_TYPE_ID,
a11.ITEM_ID

In report 05.b, <SB = Promotion@Desc asc> is ignored. In


report 05.a, there is no select attribute Promotion@Desc.
Thus, the Intelligence Server cannot perform a sort-by on
attribute Promotion@Desc.
NULL Handling in OLAP Functions
NULL is always sorted at the end. Intelligence Server sorts
NULL and places it at the end. If the computation is done in
the database, then ANSI standard for OLAP functions
requires that by default, all databases put NULL at the end.
For RunningCount or MovingCount functions, NULL will
always be ignored. For other computations, such as
RunningSum or MovingAvg, NULL will be treated as zero for
the sum of values across the function parameters. This
behavior is consistent for Intelligence Server and ANSI
database OLAP functions.

38 How Intelligence Server uses functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Tie Handling in OLAP Functions


Tie handling is related to <SB> parameter when we sort a tie
in a metric. Intelligence Server uses Merge-Sort algorithm,
which always preserves the original order presented from the
database (via ODBC) to the Intelligence Server
It is not known whether databases use the same sort
algorithm. However, the Intelligence Server and database
computation of OLAP functions can produce different results
whenever there is a tie on the data.

Business Case Examples


In this section we will provide business case examples using
the MicroStrategy Tutorial project. The warehouse and the
metadata are in Microsoft Access. You can find all the objects
built in the MicroStrategy Tutorial project in the following
location: Public Objects/Reports/Technical Reports/Reports
by feature/Analytics/Statistics and Forecasting.

Example 1: Hypothesis Testing


Which call centers provide statistically significant
decrease in the average daily sales in 2001 vs. 2000?
You want to find the average of daily sales in 2001 vs. 2000
for each call center. This example assumes that you have the
necessary data to perform the calculations and display the
report.
All of the component objects (metrics, filters, and so on) that
are used in this example can be found in the MicroStrategy
Tutorial project under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting
/Hypothesis Testing/Component Objects

2003 MicroStrategy, Inc.

Business Case Examples

39

Overview

MicroStrategy Analytical Functions Reference

The report that is built for this example is also available in


MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Hypothesis Testing
The Average Daily sales metric can be calculated as
follows:
[Average Daily Sales] = Avg(Sum([Revenue]){~+,
Day+}){~+}

Notice that this is a simple metric that contains two


group-value functions (Sum and Avg) that are nested one
after another.

40 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

We can create a report with this metric along with the


attributes Call Center on Row axis and Year on Column axis.
The following report will be displayed.

From the report Average Daily Sales in 2000 and 2001, it


looks like all call centers had a significant decrease in the
average daily sales in 2001 when compared to 2000. But
since an average value by itself does not represent the
complete picture, let us check the standard deviation of daily
sales in 2001 versus 2000 for each call center. This can be
accomplished by creating a metric with the following
definition:

2003 MicroStrategy, Inc.

Business Case Examples

41

Overview

MicroStrategy Analytical Functions Reference

[StDev Daily Sales] = StDev(Sum([Revenue]){~+,


Day+}){~+}

Thus, the following report provides a complete picture for


average and standard deviation of daily sales for both the
years, for each call center.

42 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Notice that all call centers have average daily sales for 2000
greater than the average daily sales for the next year. With the
exception of Charleston, they also have higher standard
deviations of daily sales for 2000 when compared with 2001.
This means that the volatility of daily sales in 2001 is higher
than that for 2000. Hence, we cannot state that lower average
daily sales in 2001 are a progressive decrease over 2000
because they may have been caused by random fluctuation.
Given the above observation, it is worth finding out which call
centers actually have statistically significant difference on
their average daily sales between these two years. We can get
the result by testing this hypothesis:
H0: 2000 = 2001 or H0: 2000 - 2001 = 0
against
H1: 2000 2001 or H1: 2000 - 2001 0
where: 2000 and 2001 represent the average daily sales in
2000 and 2001 respectively. We will want to test the above
hypothesis for each call center as well.
The above hypothesis testing can be answered by computing
the p-value. In Statistics, p-value is a probability of making a
decision to reject H0, given that the actual fact H0 is correct.
In the context of our example, this is the probability of
making a mistake to conclude that the average daily sales in
2000 is different from 2001, given that actually they are
about the same. In general, a decision maker wants to restrict
this type of error so that it is smaller than a certain tolerance
(commonly refer to as alpha). This alpha is usually set to
somewhere between 2.5 10.0% depending on many factors.
If we assume that the standard deviation of daily sales for
2000 and 2001 are coming from the same population (that is,
we assume that the population daily standard deviations for
both years are the same), then we can use a plug-in
group-value function called HomoscedasticTTest to compute
the p-value. However, if we assume that the population daily

2003 MicroStrategy, Inc.

Business Case Examples

43

Overview

MicroStrategy Analytical Functions Reference

standard deviations are different, then we have to use


different function called HeteroscedasticTTest. Let us
consider both these statistical assumptions, and proceed with
how we can use the Intelligence Server to compute the
p-value using HomoscedasticTTest and/or
HeteroscedasticTTest.
Step One: We will use a simple metric where the formula is
based on metrics for the following reasons.

We need to compute the Daily Sales for each call center


and for each day for both the years since our fact table
(DAY_CTR_SLS) is available at the levels of: Employee,
Order, and Day. Therefore, we need to group/aggregate
the fact [Revenue] to the appropriate levels of Day and
Call Center. Note that attribute Call Center is related to
the fact table via attribute Employee. In short, we need to
have a table with a structure similar to the following:
Call
Center

Day

Northwest

Daily Sales in
2000

Daily Sales in
2001

N
Southeast

Etc.

44 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Since, there is no table in the warehouse with the above


structure we will need to create it temporarily in the
warehouse using inner metrics of the simple metric. Let
us create an inner metric that is defined as:
[Daily Sales in 2001] = Sum([Revenue]){~+,
Day+}<2001>

Note that we put tilde plus notation (that is, ~+} for
inner metrics since tilde will be replaced by any attribute
on the report. In our example, it will be the attribute Call
Center.

Step Two: We will need to use a transformation in order to be


able to build a table structure similar to the one shown above
(for the column [Daily Sales in 2000]). This is because
attribute Day is a child of attribute Year. Therefore, to show
Daily Sales in Day 1, 2, , N of 2000 together with Daily Sales
in Day 1, 2, , N of 2001, we will have to use the last year
transformation instead of a filter <2000>.

2003 MicroStrategy, Inc.

Business Case Examples

45

Overview

MicroStrategy Analytical Functions Reference

The other inner metric then will be defined as:


[Daily Sales in 2000] = Sum([Revenue]){~+,
Day+}<2001>|[Last Years]|

You cannot use a 2000 filter on the Daily Sales metric. If we


think of the inner metrics as their own report and put
attributes Call Center and Day on a template with the
following two metrics:
[Daily Sales in 2000] = Sum([Revenue]){~+,
Day+}<2000>
[Daily Sales in 2001] = Sum([Revenue]){~+,
Day+}<2001>
then the report will not return any data. Irrespective of which
joins we select, we would never get any data by putting these
2 metrics together with the attribute Day on the report.
Hence, we use the [Last Years] transformation.
Step Three: We can now build the simple metrics to compute
the p-value for each call center by defining them as follows:

46 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

HeteroscedasticTTest<0, 0>([Daily Sales in 2000], [Daily


Sales in 2001]){~+}

HomoscedasticTTest<0, 0>([Daily Sales in 2000], [Daily


Sales in 2001]){~+}

2003 MicroStrategy, Inc.

Business Case Examples

47

Overview

MicroStrategy Analytical Functions Reference

Step Four: We can create a template with the two metrics


shown above (for p-value) along with attribute Call Center,
and the resulting report will be displayed.

48 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

The following SQL is generated for the above report.


Hypothesis Testing
Pass #01
create table ZZT2E00001WMD000 (
DAY_DATE
TIMESTAMP,
CALL_CTR_ID
BYTE,
WJXBFS1
DOUBLE)
insert into ZZT2E00001WMD000
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 (2001)
Pass #02
create table ZZT2E00001WMD001 (
DAY_DATE
TIMESTAMP,
CALL_CTR_ID
BYTE,
WJXBFS1
DOUBLE)
insert into ZZT2E00001WMD001
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 (2001)
Pass #03
select pa1.[CALL_CTR_ID] AS CALL_CTR_ID,
a11.[CENTER_NAME] AS CENTER_NAME,
pa1.[DAY_DATE] AS DAY_DATE,
pa1.[WJXBFS1] as WJXBFS1,
pa2.[WJXBFS1] as WJXBFS2,
pa1.[WJXBFS1] as WJXBFS3,
pa2.[WJXBFS1] as WJXBFS4
from [ZZT2E00001WMD000] pa1,
[ZZT2E00001WMD001] pa2,
[LU_CALL_CTR] a11
where pa1.[CALL_CTR_ID] = pa2.[CALL_CTR_ID] and
pa1.[DAY_DATE] = pa2.[DAY_DATE] and
pa1.[CALL_CTR_ID] = a11.[CALL_CTR_ID]
Pass #04
[An Analytical SQL]
drop table ZZT2E00001WMD000
drop table ZZT2E00001WMD001

2003 MicroStrategy, Inc.

Business Case Examples

49

Overview

MicroStrategy Analytical Functions Reference

Pass #01 is issued by Intelligence Server to compute the inner


metric [Daily Sales in 2000]. Notice that Intelligence Server
prepares the temporary table with Call Center and Day as its
key. Then, it brings back the sales in 2000 using
transformation that is specified as |[Last Year]|.
Pass #02 is issued to bring the inner metric [Daily Sales in
2001]. Attributes Call Center and Day are used as keys to the
temp table. This pass is similar to Pass #01. The only
difference is that there is no transformation for this inner
metric.
In the next step, the Intelligence Server computes the p-value
for each call center (using HeteroscedasticTTest and the
HomoscedasticTTest function) and inserts the value back
into the table.
The rest of the SQL erases all the temporary tables created.
Thus, referring to the report Hypothesis Testing above, we
can see that only San Francisco, Fargo and Memphis have a
p-value of less than 5%.
This indicates a strong evidence that average daily sales in
San Francisco, Fargo and Memphis for 2001 are actually
different (lower) than 2000.

Example 2: Confidence Level


Who are my valuable customers? (Definition 1)
The term valuable customers is a broad term, and we need to
be specific and define what exactly are the parameters that
that will help us identify the valuable customers from the rest
of the customers.

50 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

The ORDER_FACT table has all orders that were received in


2000 and 2001. Then, let us assume that the sales order
amount is normally distributed with a certain mean and
standard deviation (that is, in Statistics, the sales order
amount is N(m,s ) ). If we assume a = 1% , then the
confidence interval for sales orders is given by

s
s
m - za

m
+
z
,
a

n
n
2
2

These two numbers mean that 99% of sales order will fall
within this category (under the assumption of Normality).
m - za
2

m + za
2

s
n
s
n

is called Lower Bound (LB).

is called Upper Bound (UB).

So based on our assumption above, we can define our


valuable customers as those who have an average spending
above the upper bound of sales orders.
To determine the valuable customers, we need to know the
following values. First, we definitely need to know the
average sales order from all orders (from the ORDER_FACT
m
table). This will be the mean of our Normal distribution ( ).
We can get this value using the Avg function in the
Intelligence Server. Second, we need to know the standard
deviation of sales order from all orders. This number will be
the standard deviation of the Normal distribution ( s ). We
can get this value using the StDevP function in the
Intelligence Server. (Note: StDevP is standard deviation of
population, while StDev is standard deviation of sample.)
Under the assumption of Normal distribution with the
parameters given above, we need to determine the cut-off
value that represents top 5% of sales order amount. This
cut-off number can be statistically computed by the following
equation:

2003 MicroStrategy, Inc.

Business Case Examples

51

Overview

MicroStrategy Analytical Functions Reference

\ z s
m+ a
n
2

where

a = 1%

Note that in order to compute this value, we need to know n,


which is the number of rows in the ORDER_FACT table. This
is achieved using the Count function (in particular Count
from Fact table).
za

s
n

Moreover, 2
can be computed by the Intelligence Server
using the Confidence plug-in function.
Let us proceed with accomplishing these tasks using the
Intelligence Server. Since we want to get a list of valuable
customers, add the Customer attribute on the Row axis.
Moreover, we will also put Customer Region on the Page-by
axis.
All of the component objects (metrics, filters, and so on) that
are used in this example can be found in the MicroStrategy
Tutorial project under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Confidence Level/Component Objects
The report that is built for this example is also available in
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Confidence Level
The first metric to compute the average of sales order from
ORDER_FACT table (the mean parameter of the Normal
distribution) can be defined as:

52 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

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


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

Since Day, Employee, and Order are the highest attributes


which are parent of the keys in the ORDER_FACT table, we
include them {!Day+, !Employee+, !Order+} as the level of
aggregation to make sure that that we use the ORDER_FACT
table. Also, since we want the average to be performed over
all sales order amounts, we have to set the <group-by> to
none. This is to make sure that the metric does not group-by
any of these attributes.
Similarly, the second metric to compute the population
standard deviation of sales order from ORDER_FACT table
can be defined as:

2003 MicroStrategy, Inc.

Business Case Examples

53

Overview

MicroStrategy Analytical Functions Reference

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


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

We can define a count from fact metric to count the data in


the ORDER_FACT table.

54 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

M03 = Count([Revenue]) {![Call Center]+, !Year+,


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

Given all the above metrics, the cut-off number can be


computed by the following metric:
M05 = M01 + Confidence(1%, M02, M03)

2003 MicroStrategy, Inc.

Business Case Examples

55

Overview

MicroStrategy Analytical Functions Reference

Alternatively, we can define M04 = Confidence(1%, [M02],


[M03]).

Now lets define M05 = [M01] + [M04].

56 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Since we want to get a list of valuable customers based on the


above definition, we will create another metric that computes
the average sales for each customer.
Average Sales = Avg([Revenue]){~+}

Note that we do not need to include the level of aggregation


for Average Sales since the tilde notation will be replaced by
attribute Customer.
Since we want to restrict the number of rows returned, we
will define a Metric Qualification <MQ> filter with the
following definition:

2003 MicroStrategy, Inc.

Business Case Examples

57

Overview

MicroStrategy Analytical Functions Reference

F01 = Average Sales greater than M05 with output level


{Customer}

58 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Filter F01 together with attribute Customer on Row axis and


attribute Customer Region on Page-by axis will give us a list
of valuable customers for each attribute element in Customer
Region. The following Valuable Customers 01 report is
displayed.

The following SQL will be generated for this report.


Valuable Customers 01
Pass #01
create table ZZT2E010053MD000 (
SHORT,
WJXBFS1
FLOAT)

CUSTOMER_ID

insert into ZZT2E010053MD000


select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[TOT_DOLLAR_SALES] as WJXBFS1
from [CUSTOMER_SLS] a11
Pass #02
select a11.[ORDER_ID] AS ORDER_ID,
a11.[EMP_ID] AS EMP_ID,
a11.[ORDER_DATE] AS DAY_DATE,
a12.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[ORDER_AMT] as WJXBFS1
from [ORDER_FACT] a11,
2003 MicroStrategy, Inc.

Business Case Examples

59

Overview

MicroStrategy Analytical Functions Reference

[LU_ORDER] a12
where a11.[ORDER_ID] = a12.[ORDER_ID]
create table ZZT2E010053MD001 (
CUSTOMER_ID
SHORT,
WJXBFS1
FLOAT)
[An Analytical SQL]
insert into ZZT2E010053MD001
values (26, 105.386485104625)
Pass #03
create table ZZT2E010053MQ002 (
CUSTOMER_ID
SHORT)
insert into ZZT2E010053MQ002
select pa1.[CUSTOMER_ID] AS CUSTOMER_ID
from [ZZT2E010053MD000] pa1,
[ZZT2E010053MD001] pa2
where pa1.[CUSTOMER_ID] = pa2.[CUSTOMER_ID]
and (pa1.[WJXBFS1] > pa2.[WJXBFS1])
Pass #04
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a12.[CUST_LAST_NAME] AS CUST_LAST_NAME,
a12.[CUST_FIRST_NAME] AS CUST_FIRST_NAME,
a14.[CUST_REGION_ID] AS CUST_REGION_ID,
a15.[CUST_REGION_NAME] AS CUST_REGION_NAME,
a11.[TOT_DOLLAR_SALES] as WJXBFS1
from [CUSTOMER_SLS] a11,
[ZZT2E010053MQ002] pa3,
[LU_CUSTOMER] a12,
[LU_CUST_CITY] a13,
[LU_CUST_STATE] a14,
[LU_CUST_REGION] a15
where a11.[CUSTOMER_ID] = pa3.[CUSTOMER_ID] and
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]
drop table ZZT2E010053MD000
drop table ZZT2E010053MD001
drop table ZZT2E010053MQ002

60 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Pass #01 brings back the average sales per customer (Average
Sales metric) and puts the result into a temporary table.
Pass #02 brings three ORDER_AMT facts, puts them into the
memory, and uses them to compute M01, M02, and M03.
Note that in order to compute M05, the Intelligence Server
needs to bring facts for M01, M02, and M03, then perform
group-value functions on the top of three ORDER_AMT
facts, and insert the result back into a temporary table.
Note that the group-value function for M02 (the StDevP
function) is not supported by the database (Microsoft
Access). Thus, the Intelligence Server brings all 3
ORDER_AMT facts to perform computations for Avg, StDev,
and Count functions.
Pass #03 uses the earlier two temporary tables to qualify on
valuable customers based on Definition 01.
The next pass (Pass #04) is needed to display the report with
attributes Customer and Customer Region.
Who are my valuable customers? (Definition 2)
The basic notion of valuable customers is to define a cut-off
value which represents a minimum requirement to be
classified as valuable customers. Let us generate a list of
valuable customers based on the following definition.
Let us assume a Normal distribution of sales order is still
valid and we want the cut-off value to be different for each
attribute element of Customer Region. This means
comparing the average spending of each customer against a
number that reflects the average spending of Customer
Region to which the customer belongs. To make it a little bit
interesting, lets take the average value to be computed from
the year with the highest dollar sales (that is, 2000 data).
However, we want to use sample standard deviations for all
available years (both 2000 and 2001) to allow more
variation.
So lets define the cut-off value for each Customer Region to
be: 2000 + 1.96 x s2000+2001

2003 MicroStrategy, Inc.

Business Case Examples

61

Overview

MicroStrategy Analytical Functions Reference

Notice that the number 1.96 comes from a Normal


distribution with 95% confidence level. In practice, people
often round this number to 2 instead of 1.96.
All of the component objects (metrics, filters, and so on) that
are used in this example can be found in the MicroStrategy
Tutorial project under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Confidence Level/Component Objects
The report that is built for this example is also available in
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Confidence Level
So we define the valuable customers as those customers who
have total spending (over all times) above the cut-off value.
The cut-off value for valuable customers can be accomplished
by the following filters and metrics:
2001 = Year in (2001)

62 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

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


!Employee+, !Order+, !Day+}<2001>

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


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

2003 MicroStrategy, Inc.

Business Case Examples

63

Overview

MicroStrategy Analytical Functions Reference

Metric M09 is the cut-off value according to the earlier


definition.
M09 = M07 + 1.96 * M08

We will have to compare this cut-off number (M09 metric


value) with customers spending. Every customer spending
can be computed by a metric that is defined as:

64 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

M10 = Sum([Revenue]){~+}

Create a Metric Qualification <MQ> filter to obtain the list of


valuable customers based on Definition 2 :
F03 = M10 greater than M09 with output level {Customer}

2003 MicroStrategy, Inc.

Business Case Examples

65

Overview

MicroStrategy Analytical Functions Reference

We would also like to see the last order sales from all valuable
customers. This number can be computed by the following
metric:
Last Order Sales = Sum([Revenue]){~+, >|Day+}

Note that we need to compute order sales for each customer


at the Day level from ORDER_FACT table, but we have to
pick it from the last Day on that fact table. The tilde will be
replaced by any attribute on the report. In our example, it will
be the attribute Customer.

66 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

We can then build a report using: attribute Customer on Row


axis, attribute Customer Region on Page-by axis, Last Order
Sales metric on Column axis, and F03 as the filter. The
following Valuable Customers 02 report will be displayed.

The following SQL will be generated by the above report.


Valuable Customers 02
Pass #01
create table ZZT2E01003GMD000 (
CUSTOMER_IDSHORT,
WJXBFS1DOUBLE)
insert into ZZT2E01003GMD000
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[TOT_DOLLAR_SALES] as WJXBFS1
from [CUSTOMER_SLS] a11
Pass #02
create table ZZT2E01003GMD001 (
CUST_REGION_IDBYTE,
WJXBFS1FLOAT)
insert into ZZT2E01003GMD001
select a15.[CUST_REGION_ID] AS CUST_REGION_ID,
avg(a11.[ORDER_AMT]) as WJXBFS1
from [ORDER_FACT] a11,

2003 MicroStrategy, Inc.

Business Case Examples

67

Overview

MicroStrategy Analytical Functions Reference

[LU_ORDER] a12,
[LU_CUSTOMER] a13,
[LU_CUST_CITY] a14,
[LU_CUST_STATE] a15,
[LU_DAY] 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
a11.[ORDER_DATE] = a16.[DAY_DATE]
anda16.[YEAR_ID] in (2001)
group by a15.[CUST_REGION_ID]
Pass #03
select a11.[ORDER_ID] AS ORDER_ID,
a11.[EMP_ID] AS EMP_ID,
a11.[ORDER_DATE] AS DAY_DATE,
a15.[CUST_REGION_ID] AS CUST_REGION_ID,
a11.[ORDER_AMT] as WJXBFS1
from [ORDER_FACT] a11,
[LU_ORDER] a12,
[LU_CUSTOMER] a13,
[LU_CUST_CITY] a14,
[LU_CUST_STATE] a15
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]
create table ZZT2E01003GMD002 (
CUST_REGION_IDBYTE,
WJXBFS1DOUBLE)

[An Analytical SQL]


insert into ZZT2E01003GMD002 values (3,
361.276979147296)
Pass #04
create table ZZT2E01003GMQ003 (
CUSTOMER_IDSHORT)

insert into ZZT2E01003GMQ003


select pa1.[CUSTOMER_ID] AS CUSTOMER_ID
from [ZZT2E01003GMD000] pa1,
[LU_CUSTOMER] a11,
[LU_CUST_CITY] a12,

68 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

[LU_CUST_STATE] a13,
[ZZT2E01003GMD001] pa2,
[ZZT2E01003GMD002] pa3
where pa1.[CUSTOMER_ID] = a11.[CUSTOMER_ID] and
a11.[CUST_CITY_ID] = a12.[CUST_CITY_ID] and
a12.[CUST_STATE_ID] = a13.[CUST_STATE_ID] and
a13.[CUST_REGION_ID] = pa2.[CUST_REGION_ID] and
pa2.[CUST_REGION_ID] = pa3.[CUST_REGION_ID]
and(pa1.[WJXBFS1] > (pa2.[WJXBFS1] +
pa3.[WJXBFS1]))
Pass #05.a
create table ZZT2E01003GNB004 (
DAY_DATETIMESTAMP,
CUSTOMER_IDSHORT,
WJXBFS1DOUBLE)

insert into ZZT2E01003GNB004


select a11.[ORDER_DATE] AS DAY_DATE,
a12.[CUSTOMER_ID] AS CUSTOMER_ID,
sum(a11.[ORDER_AMT]) as WJXBFS1
from [ORDER_FACT] a11,
[LU_ORDER] a12,
[ZZT2E01003GMQ003] pa4
where a11.[ORDER_ID] = a12.[ORDER_ID] and
a12.[CUSTOMER_ID] = pa4.[CUSTOMER_ID]
group by a11.[ORDER_DATE],
a12.[CUSTOMER_ID]
Pass #05.b
create table ZZT2E01003GMB005 (
CUSTOMER_IDSHORT,
WJXBFS1TIMESTAMP)

insert into ZZT2E01003GMB005


select pa5.[CUSTOMER_ID] AS CUSTOMER_ID,
max(pa5.[DAY_DATE]) as WJXBFS1
from [ZZT2E01003GNB004] pa5
group by pa5.[CUSTOMER_ID]
Pass #06
select distinct pa5.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[CUST_LAST_NAME] AS CUST_LAST_NAME,
a11.[CUST_FIRST_NAME] AS CUST_FIRST_NAME,
a13.[CUST_REGION_ID] AS CUST_REGION_ID,
a14.[CUST_REGION_NAME] AS CUST_REGION_NAME,

2003 MicroStrategy, Inc.

Business Case Examples

69

Overview

MicroStrategy Analytical Functions Reference

pa5.[WJXBFS1] as WJXBFS1
from [ZZT2E01003GNB004] pa5,
[ZZT2E01003GMB005] pa6,
[LU_CUSTOMER] a11,
[LU_CUST_CITY] a12,
[LU_CUST_STATE] a13,
[LU_CUST_REGION] a14
where pa5.[CUSTOMER_ID] = pa6.[CUSTOMER_ID] and
pa5.[DAY_DATE] = pa6.[WJXBFS1] and
pa5.[CUSTOMER_ID] = a11.[CUSTOMER_ID] and
a11.[CUST_CITY_ID] = a12.[CUST_CITY_ID] and
a12.[CUST_STATE_ID] = a13.[CUST_STATE_ID] and
a13.[CUST_REGION_ID] = a14.[CUST_REGION_ID]
drop table ZZT2E01003GMD000
drop table ZZT2E01003GMD001
drop table ZZT2E01003GMD002
drop table ZZT2E01003GMQ003
drop table ZZT2E01003GNB004
drop table ZZT2E01003GMB005

Pass #01 is for computing metric M10.


Pass #02 is for computing M07.
Pass #03 is used for computing (1.96 * M08). Note that the
group-value function for M08 (the StDevP function) is not
supported by the database (Microsoft Access). Thus it is
calculated by the Intelligence Server.
Pass #04 is needed to obtain all valuable customers (for
evaluating filter condition for MQ filter in F03).
Passes #05.a and #05.b are used to compute Last Order Sales
metric.
Pass #06 is needed to display the results for the report.

70 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Example 3: Histogram
How are my customers distributed (classified) based
on sales data?
You are interested in finding out how are your customers
distributed (classified) based on their sales (fact Revenue)
data. We will try to segment them into 10 classes:

Customers who spend in the lowest 10% of the sales,

Customers who spend in the second 10% of the sales,

Customer who spend in the ninth 10% of the sales, and

Customer who spend in the top 10 of the sales%

When we begin, we do not have any specific knowledge about


how much each customer spends. Hence, the range of sales
for each customer (in theory) can be from 0 to infinity. Let us
suppose that a customer spends between $100 to $10,000
(Note: This does not represent the actual data in
MicroStrategy Tutorial. In fact, in MicroStrategy Tutorial,
there are 10,000 customers whose spending range between
$163 $7,171.). Since we assume that a customer spends
between $100 to $10,000, the sales range of all customers
will be 10,000 100 = 9,900. If we divide this range into 10
classes, we can find out how many customers spend between
$100 $1,090 (this is the lowest 10%), how many customer
spends between $1,090 $2,800 (this is the second 10%), ,
how many customers spends between $8,020 $9,010 (this
is the ninth class), and the top class is defined as any
customers who spend between $9,010 $10,000.
If we plot the data, it will give us a histogram that gives a
statistical indication of how sales are distributed across our
customers.
There are several obstacles that need to be overcome here.
The warehouse only records sales of each customer. There is
no knowledge of the minimum and maximum sales. Second,
by default there is no such classification of customers.

2003 MicroStrategy, Inc.

Business Case Examples

71

Overview

MicroStrategy Analytical Functions Reference

All of the component objects (metrics, filters, and so on) that


are used in this example can be found in the MicroStrategy
Tutorial project under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Histogram/Component Objects
The report that is built for this example is also available in
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Histogram
Notice that there are 3 types of objects here, a graph
(histogram), a grid report, and a document object to
represent the same calculation.
To answer this specific question, we will use the following
concepts:

Analytical functions: NTileValue, and

Custom group.

NTileValue is specifically designed to put certain numbers


into several different tiles based on the minimum and
maximum value. In particular, all customers that fall in the
first bucket will be denoted as 1, all customers in the second
bucket will be denoted as 2, , and finally all customers in the
10th bucket will be denoted as 10. This function is computed
by the Intelligence Server. We can then use this metric to
create a dynamic classification of Customers using a custom
group.
To make a general solution, we will use prompts (specifically
an object prompt) so that the final report can be used by
various managers.
We will create the following object prompts:

72 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Chose a base fact this object prompt asks the user to


select facts: [Revenue], [Profit], or [Unit Sold].

Chose a sample set level this object prompt asks the


user to select attributes: Customer, Item, or Day.

Once we have the basic fact and attribute to analyze in


prompt (to provide flexibility), we can start building other
objects.
In particular, we have to define a metric that has the
following definition:

2003 MicroStrategy, Inc.

Business Case Examples

73

Overview

MicroStrategy Analytical Functions Reference

Sample Set Metric = Sum(?[Choose a base fact]){~+,


?[Choose a sample set level]}

To put the value in the proper buckets (tiles), we create


another metric that is defined as:

74 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Decile By Value = NTileValue<Segments=10>([Sample Set


Metric])

2003 MicroStrategy, Inc.

Business Case Examples

75

Overview

MicroStrategy Analytical Functions Reference

And to create a dynamic classification of our subject attribute


(Customers, Item, or Day), we have to build a custom group
using banding. We use metric Decile By Value to create a
banding using band count (to create 10 band counts) that
start at 1 and stop at 10. Since the objective is to build a graph
(histogram), for this custom group we choose to show only
individual items within this element (see the following
picture).

To display a histogram, we have to count the number of


elements in the new classification. To achieve this, we can
create a dummy metric such as:

76 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Count of Samples = Count(1){~+}

Notice how the metric is defined. Obviously, there is no


column to perform the count. We define this metric so that
the database can calculate how many attribute elements are
in each custom group element.
Add the Decile by Value custom group to the row axis, and
the Count of Samples metric to the Column axis. Execute the
report with attribute Customer and fact [Revenue], and the
following Decile Histogram - Grid report will be displayed.

2003 MicroStrategy, Inc.

Business Case Examples

77

Overview

MicroStrategy Analytical Functions Reference

The same report when displayed in graph mode is shown


below:

The following SQL is generated for this report.


Decile Histogram Grid]

Pass #01
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
a11.[TOT_DOLLAR_SALES] as WJXBFS1
from [CUSTOMER_SLS] a11
Pass #02
create table ZZT0100SRBMMQ000 (
CUSTOMER_ID
SHORT,
DA56 LONG)
Pass #03
[An Analytical SQL]
Pass #04
insert into ZZT0100SRBMMQ000 values (1, 2)
Pass #05
select a11.[DA56] AS DA56,
count(1.0) as WJXBFS1
from [ZZT0100SRBMMQ000] a11
group by a11.[DA56]
drop table ZZT0100SRBMMQ000

Pass #01 is used to pull metric [Sample Set Metric], that is,
[Revenue] for each Customer.

78 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

The next three passes (Passes #02, Pass #03, and Pass #04)
are used to prepare the dynamic classification of Customer
into the custom group. In some sense, this series of SQL
passes are used for building a dynamic lookup table for the
classification that is requested (note that column DA that is
created stands for Dynamic Attribute). Note that the function
NTileValue is computed by the Intelligence Server. It is then
inserted back with the new classification into the dynamic
lookup table for the custom group.
Pass #05 calculates the number of customers that belong to
each custom group element.

Example 4: Statistical Descriptors - Simple


How do I learn more about my customers?
You are interested in learning more about your customers in
each region [Customer Region]. We can get this information
from performing statistical calculations on their spending. In
particular, we would like to know the following statistics:

How many customers exist in each Customer Region

What is the mean (average) spending of customer in each


Customer Region

What is the median spending of customer in each


Customer Region

What is the standard deviation of customers spending in


each Customer Region

How much is the 25th and 75th percentile of customers


spending in each Customer Region

These are statistical descriptors about customers in each


Customer Region. This type of data will help us understand
how customers spend their money. These descriptors are not
a simple Sum function for each Customer Region, but
instead, give us a more detailed behavior on each Customer
Region.
All of the component objects (metrics) that are used in this
example can be found in the MicroStrategy Tutorial project
under the following folder:
2003 MicroStrategy, Inc.

Business Case Examples

79

Overview

MicroStrategy Analytical Functions Reference

MicroStrategy Tutorial/Public Objects/Reports


/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Statistical Descriptors/Component Objects
The report that is built for this example is also available in
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Statistical Descriptors
In addition to this simple example, there is also a set of
metrics that are constructed using object prompt to provide
more flexibility for users. These can be easily identified in the
same folder.
To answer the above questions, we can build a set of simple
metrics whose formulae are based on other metrics. These
metrics are defined using the nested structure of group-value
functions.
Count of Customers = Sum(Count(1){~+, Customer
}){~+}

80 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

a.Mean Revenue Per Customer =


Avg(Sum[Revenue]){~+ , Customer+}){~+}

b.Median Revenue Per Customer =


Median(Sum[Revenue]{~+ , Customer+}){~+}

2003 MicroStrategy, Inc.

Business Case Examples

81

Overview

MicroStrategy Analytical Functions Reference

e.StDev of Revenue Per Customer =


Stdev(Sum[Revenue]{~+ , Customer+}){~+}

25th Percentile of Revenue Per Customer =


Percentile(Sum[Revenue]{~+ , Customer+}, 0.25){~+}

82 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

75th Percentile of Revenue Per Customer =


Percentile(Sum[Revenue]{~+ , Customer+}, 0.75){~+}

We can place the above metrics on the row axis along with
attribute Customer Region on the column axis, to get the
following Statistical Descriptors - Simple report.

The above report gives us an indication about the behavior of


customers spending in each Customer Region. For example,
Northwest customer region has the least number of
customers, but most customers in that region spend more
than other region.
The following SQL is generated for the report:
Report [Statistical Descriptors Simple]

Pass #01
create table ZZTXS00VL3ZMD000 (
CUSTOMER_IDSHORT,

2003 MicroStrategy, Inc.

Business Case Examples

83

Overview

MicroStrategy Analytical Functions Reference

WJXBFS1LONG,
WJXBFS2DOUBLE)
Pass #02
insert into ZZTXS00VL3ZMD000
select a11.[CUSTOMER_ID] AS CUSTOMER_ID,
1 as WJXBFS1,
a11.[TOT_DOLLAR_SALES] as WJXBFS2
from [CUSTOMER_SLS] a11
Pass #03
select pa1.[CUSTOMER_ID] AS CUSTOMER_ID,
a13.[CUST_REGION_ID] AS CUST_REGION_ID,
a14.[CUST_REGION_NAME] AS CUST_REGION_NAME,
pa1.[WJXBFS1] as WJXBFS1,
pa1.[WJXBFS2] as WJXBFS2,
pa1.[WJXBFS2] as WJXBFS3,
pa1.[WJXBFS2] as WJXBFS4,
pa1.[WJXBFS2] as WJXBFS5,
pa1.[WJXBFS2] as WJXBFS6
from [ZZTXS00VL3ZMD000] pa1,
[LU_CUSTOMER] a11,
[LU_CUST_CITY] a12,
[LU_CUST_STATE] a13,
[LU_CUST_REGION] a14
where pa1.[CUSTOMER_ID] = a11.[CUSTOMER_ID] and
a11.[CUST_CITY_ID] = a12.[CUST_CITY_ID] and
a12.[CUST_STATE_ID] = a13.[CUST_STATE_ID] and
a13.[CUST_REGION_ID] = a14.[CUST_REGION_ID]
Pass #04
[An Analytical SQL]

drop table ZZTXS00VL3ZMD000

The first two passes of SQLs (Pass #01 and Pass #02) are
used to prepare and pull 2 inner metrics, namely:
Count(1){~+, Customer+}, and
Sum[Revenue]{~+, Customer+}.
Notice the optimization that the Intelligence Server does to
pull only a single column of Sum[Revenue] even though it is
used in several other metrics.

84 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Pass #03 and Pass #04 are again very interesting to


understand. Notice how the Intelligence Server pulls results
from Pass #02 to compute the outer metrics. First, notice that
column pa1.[WJXBFS2] (which is essentially
Sum[Revenue]{~+, Customer+}) is pulled 5 times, each
column corresponding to each metric (this is in Pass #03).
We can assume that this is a table in memory (lets call this
table IMT = In-Memory Table). So, essentially Pass #03 is
equivalent to a SQL statement such as:

Pass #03_Equivalent:
insert into IMT as
select pa1.[CUSTOMER_ID] AS CUSTOMER_ID,
a13.[CUST_REGION_ID] AS CUST_REGION_ID,
a14.[CUST_REGION_NAME] AS CUST_REGION_NAME,
pa1.[WJXBFS1] as WJXBFS1,
pa1.[WJXBFS2] as WJXBFS2,
pa1.[WJXBFS2] as WJXBFS3,
pa1.[WJXBFS2] as WJXBFS4,
pa1.[WJXBFS2] as WJXBFS5,
pa1.[WJXBFS2] as WJXBFS6
from [ZZTXS00VL3ZMD000] pa1,
[LU_CUSTOMER] a11,
[LU_CUST_CITY] a12,
[LU_CUST_STATE] a13,
[LU_CUST_REGION] a14
where pa1.[CUSTOMER_ID] = a11.[CUSTOMER_ID] and
a11.[CUST_CITY_ID] = a12.[CUST_CITY_ID] and
a12.[CUST_STATE_ID] = a13.[CUST_STATE_ID] and
a13.[CUST_REGION_ID] = a14.[CUST_REGION_ID]

Second, also notice that the Intelligence Server actually acts


as an in-memory database which calculates the following
group-value functions: Sum, Avg, Median, Stdev, and
Percentile. Analytical calculations are computed which are
essentially doing an equivalent of the following SQL (Pass
#04):

Pass #04_Equivalent:
select [CUST_REGION_ID] AS CUST_REGION_ID,
Max([CUST_REGION_NAME]) AS CUST_REGION_NAME,
Sum(WJXBFS1),
Avg(WJXBFS2),
Median(WJXBFS3),
Stdev(WJXBFS4),

2003 MicroStrategy, Inc.

Business Case Examples

85

Overview

MicroStrategy Analytical Functions Reference

Percentile(WJXBFS5, 25%),
Percentile(WJXBFS6, 75%)
from IMT
group by [CUST_REGION_ID]

In the last passes, the temporary tables are dropped from the
database.

Example 5: Forecasting
How to forecast future sales based on existing sales
data?
The MicroStrategy Tutorial project has existing sales data for
the years 2000 and 2001. Using this data, you would like to
forecast potential sales for the upcoming years 2002 and
2003. We would like to apply linear extrapolation techniques
to the historical data to plot a sales line for future data.
Linear extrapolation involves the assumption that the trend
of past data will continue in a linear fashion. The slope and
Y-intercept values of this approximation are calculated based
on historical data, and the same slope and Y-intercept are
applied to extend the line into the future.
All of the component objects (metrics) that are used in this
example can be found in the MicroStrategy Tutorial project
under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Forecasting/Component Objects
The report that is built for this example is also available in
MicroStrategy Tutorial under the following folder:
MicroStrategy Tutorial/Public Objects/Reports
/Technical Reports/Reports by Feature/
Analytics/Statistics and Forecasting/
Forecasting

86 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

To perform the analysis, build a set of metrics which calculate


each of the components in the linear extrapolation analysis,
then use those metrics together to create the final Forecasting
metric. The metrics are defined as follows:
Create a metric that calculates sales revenue at the Year level.
Revenue {Year} = Sum[Revenue] {~+, Year+}

Create a metric that expresses the Year elements as a series of


integers, to simplify the analysis.

2003 MicroStrategy, Inc.

Business Case Examples

87

Overview

MicroStrategy Analytical Functions Reference

YearNumber = RunningSum<SortBy= (Year@ID)


>(Sum(1) {~+, Year } )

Create a metric that calculates the slope of the line produced


by the Revenue {Year} metric.

88 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

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


{~+, !Year+}

Create a metric that calculates the Y-intercept of the line


produced by the Revenue {Year} metric.

2003 MicroStrategy, Inc.

Business Case Examples

89

Overview

MicroStrategy Analytical Functions Reference

InterceptMetric = Intercept([[Revenue] {Year}],


YearNumber) {~+, !Year+}

Create a metric that synthesizes the above three metrics into


a forecast value. Notice that this formula follows the
standard formula for a line: y = mx + b

90 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Forecast = ((SlopeMetric * YearNumber) +


InterceptMetric)

2003 MicroStrategy, Inc.

Business Case Examples

91

Overview

MicroStrategy Analytical Functions Reference

When the [Forecast] metric is placed on a report with Year


(and possibly other attributes), a sales forecast is generated
for all available years.

The sales for 2000 and 2001 are actual recorded values, and
the sales for 2002 and 2003 are a linear extrapolation of the
existing data into the future.
Note: There is another report in the Forecasting folder:
Forecast (Grid). This report places the Forecast metric
alongside the Revenue metric for comparison. However, this
report requires the use of outer joins to work properly. The
MicroStrategy Tutorial ships with Microsoft Access as its
default database; in order for this report to work, the Tutorial
warehouse must be moved into a database platform that fully
supports outer joins.
The following SQL is generated for the Forecast (Graph)
report.
Forecast (Graph) report:
Pass #01
create table ZZT6K0100HMMD000 (
YEAR_IDSHORT,
CATEGORY_IDBYTE,
WJXBFS1DOUBLE)
Pass #02

92 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

insert into ZZT6K0100HMMD000


select a11.[YEAR_ID] AS YEAR_ID,
a11.[CATEGORY_ID] AS CATEGORY_ID,
a11.[TOT_DOLLAR_SALES] as WJXBFS1
from [YR_CATEGORY_SLS] a11
Pass #03
select a12.[YEAR_ID] AS YEAR_ID,
a11.[CATEGORY_ID] AS CATEGORY_ID,
sum(1.0) as WJXBFS1
from [LU_CATEGORY] a11,
[LU_YEAR] a12
group by a12.[YEAR_ID],
a11.[CATEGORY_ID]
Pass #04
create table ZZT6K0100HMMD001 (
YEAR_IDSHORT,
CATEGORY_IDBYTE,
WJXBFS1DOUBLE,
WJXBFS2DOUBLE,
WJXBFS3DOUBLE)
Pass #05
[An Analytical SQL]
Pass #06
insert into ZZT6K0100HMMD001 values (2000, 1, 1,
1, 1)
Pass #07
select pa1.[YEAR_ID] AS YEAR_ID,
pa1.[CATEGORY_ID] AS CATEGORY_ID,
pa1.[WJXBFS1] as WJXBFS1,
pa2.[WJXBFS1] as WJXBFS2,
pa1.[WJXBFS1] as WJXBFS3,
pa2.[WJXBFS3] as WJXBFS4
from [ZZT6K0100HMMD000] pa1,
[ZZT6K0100HMMD001] pa2
where pa1.[CATEGORY_ID] = pa2.[CATEGORY_ID] and
pa1.[YEAR_ID] = pa2.[YEAR_ID]
Pass #08
create table ZZT6K0100HMMD002 (
CATEGORY_IDBYTE,
WJXBFS1DOUBLE,
WJXBFS2DOUBLE)
Pass #09

2003 MicroStrategy, Inc.

Business Case Examples

93

Overview

MicroStrategy Analytical Functions Reference

[An Analytical SQL]


Pass #10
insert into
ZZT6K0100HMMD002 values (1, -559.25, 33788.25)
Pass #11
select pa2.[CATEGORY_ID] AS CATEGORY_ID,
a11.[CATEGORY_DESC] AS CATEGORY_DESC,
pa2.[YEAR_ID] AS YEAR_ID,
((pa3.[WJXBFS1] * pa2.[WJXBFS2]) + pa3.[WJXBFS2])
as WJXBFS1
from [ZZT6K0100HMMD001] pa2,
[ZZT6K0100HMMD002] pa3,
[LU_CATEGORY] a11
where pa2.[CATEGORY_ID] = pa3.[CATEGORY_ID] and
pa2.[CATEGORY_ID] = a11.[CATEGORY_ID]
drop table ZZT6K0100HMMD000
drop table ZZT6K0100HMMD001
drop table ZZT6K0100HMMD002

The first two passes above (Pass #01 and Pass #02) calculate
the Revenue {Year} metric. The next pass (Pass #03)
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 None; this forces the
metric into its own pass of SQL (instead of sharing Pass #02
with the Revenue {Year} metric). This way, all years in the
lookup table get numbered, and not just the years with data
in the fact table.
In passes #04 to #10, the YearNumber, SlopeMetric and
InterceptMetric metrics are calculated. All of these use the
Intelligence Server to perform the calculations based on the
data in the temporary table from passes #01 to #03. Values
are calculated and inserted back into the warehouse.
Finally in Pass #11, the Forecast metric is calculated based on
the information from all of the above calculation. The mx+b
calculation can be clearly seen in the SQL.
In the last three passes, the temporary tables are dropped
from the database.

94 Business Case Examples

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Overview

Defining custom plug-in functions


The MicroStrategy Function Plug-In Wizard can be used for
defining custom functions relevant to your business case
scenarios. The Intelligence Server makes no distinction
between these custom functions and the ones provided by
default. These custom plug-in functions are indistinguishable
from all other functions or operators, such as Sum, Average,
Min, Max, Count, -, +, /, or *. The Intelligence Server can also
perform standard computations such as Sum, Average, +, /,
and so on that are usually calculated by the database.
The Function Plug-In Wizard guides you through the creation
of a Microsoft Visual C++ project with placeholders where
you can add custom analytic code. After adding your
function-specific C++ code and building your project, you can
launch MicroStrategy Desktop and import your new function
plug-in to be used for all the reports.

2003 MicroStrategy, Inc.

Defining custom plug-in functions

95

Overview

96 Defining custom plug-in functions

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

2
BANDING FUNCTIONS

Introduction
Banding is used to differentiate displayed data on a report. In
MicroStrategy 7i, banding functions include the following
types:

Banding (bands have a uniform number of rows)

BandingC (there is a specific number of bands)

BandingP (bands are determined by limit values)

The text that follows addresses each of these band types.

2003 MicroStrategy, Inc.

97

Banding Functions

MicroStrategy Analytical Functions Reference

Banding
Groups metric data into equal intervals and assigns values to
the resulting metric (for example, dollar sales shown in bands
0 - 5000, 5001 - 10,000, 10,001 - 15,000, and so on).

Syntax
This function accepts four arguments, as follows:
Banding (M1, StartAt, StopAt, StepSize), where

M1 is a metric

StepSize is the width of each band

StartAt and StopAt indicate the beginning and the end of


each band

BandingC
Groups metric data into a specified number of bands and
assigns values to the resulting metric (for example, a total of
25,000 in dollar sales shown in five equal bands.).

Syntax
This function accepts four arguments, as follows:
BandingC (M1, StartAt, StopAt, BandCount), where

98 Banding

M1 is a metric

BandCount is the number of bands into which the total is


divided

StartAt and StopAt indicate the beginning and the end of


each band

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Banding Functions

BandingP
Groups metric data into bands identified by boundary point
values (for example, 0 - 5000, 5000 - 20,000, 20,000 30,000).

Syntax
This function accepts arguments as follows:
BandingP (M1, Boundary1, Boundary2, Boundary3...),
where

M1 is a metric

Boundaryn is a band-limit value

n is equal to ( number of bands + 1)

Banding qualification in custom groups


The MicroStrategy 7i Custom Group Editor allows
application of Banding, BandingC, and BandingP functions to
custom groups. The following applies to this functionality:

Banding is accessed by selecting Add a Custom Group


Banding qualification under Custom Group Options
on the Custom Group Editor interface.

Once you have selected a metric for qualification, the


dialog allows you to select banding on:
value (the metric is used directly for creating bands)
rank (ranking is applied to the selected attribute and
the banding type is applied to the result)
percent (ranking of the selected attribute is displayed
as a percent set and the banding type is applied to the
result)

2003 MicroStrategy, Inc.

BandingP

99

Banding Functions

MicroStrategy Analytical Functions Reference

This dialog also allows you to select a banding type.


Options are as follows:
Band Size (to group displayed values in bands of
equal span; see Banding)
Band Count (to group displayed values in a specific
number of bands; see BandingC)
Banding Points (to group displayed values in bands
of varying widths; see BandingP)

This function also allows you to select the output level at


which the metric is to be calculated.

Examples
The following examples given in cases 1 through 4 are based
on a report as shown in the figure, with the following
conditions present:

100 Examples

the metric is [NORMAL SALES], defined as SUM([Dollar


Sales])

the attribute is [Customer]

in all cases, evaluation takes place at the attribute level

the filter is empty

data is taken from the table ORDER_FACT, which


contains sales data for 677 customers

the highest SALES value is 3,621 (customer Jill Widen,


shown)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Banding Functions

the lowest SALES value is 4 (not shown)

Case 1
Banding type: band size (Banding)

metric: NORMAL SALES

band on: metric value

start at: 1

stop at: 4000

step size: 100

Display behavior

2003 MicroStrategy, Inc.

The engine creates 40 bands, grouping customers by total


sales amount in increments of 100 ( (4000 / 100 = 40).

Sales range is the report requirement.

Examples

101

Banding Functions

MicroStrategy Analytical Functions Reference

Display content bands the attribute [Customer] as


follows:
band 1: 1 [NORMAL SALES] < 100
band 2: 100 [NORMAL SALES] < 200
... ... ... ... ... ... ... ... ... ... ... ...
band 40: 3900 [NORMAL SALES] < 4000

Case 2
Banding type: band size (Banding)

metric: NORMAL SALES

band on: metric rank

start at: 1

stop at: 50

step size: 10

Display behavior

102 Examples

The behavior of the display is very similar to that in Case


1. The difference is that, in this case, banding is done on
metric rank (rank ([NORMAL SALES])), rather than on
the metric itself. The engine creates 5 bands, each
containing 10 customers.

5 bands, each containing 10 elements is the report


requirement.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Banding Functions

Display content bands the attribute [Customer] as


follows:
band 1: top 10 in sales (0 < rank of [NORMAL
SALES] 10)
band 2: next 10 in sales (10 < rank of [NORMAL
SALES] 20)
band 3: next 10 in sales (20 < rank of [NORMAL
SALES] 30)
band 4: next 10 in sales (30 < rank of [NORMAL
SALES] 40)
band 5: next 10 in sales (40 < rank of [NORMAL
SALES] 50)

Case 3
Banding type: band count (BandingC)

metric: NORMAL SALES

band on: metric value

start at: 1

stop at: 4000

band count: 10

Display behavior

2003 MicroStrategy, Inc.

The engine creates 10 bands, grouping customers by total


sales amount. in increments of 400 (4000 / 10 = 400).

The number of bands is the report requirement.

Examples

103

Banding Functions

MicroStrategy Analytical Functions Reference

Display contents band the attribute [Customer] as


follows:
band 1: 1 [NORMAL SALES] < 400
band 2: 400 [NORMAL SALES] < 800
... ... ... ... ... ... ... ... ... ... ... ...
band 10: 3600 [NORMAL SALES] < 4000

Case 4
Banding type: banding points (BandingP)

metric: NORMAL SALES

band on: metric value

start at: n.a.

stop at: n.a.

banding points: 20, 40, 80, 160, 320

Display behavior

The engine creates 4 bands (number of points - 1), using


customer total sale amounts as threshold values.

Each band size is user-specified.

Display content bands the attribute [Customer] as


follows:
band 1: 20 [NORMAL SALES] < 40
band 2: 40 [NORMAL SALES] < 80
band 3: 80 [NORMAL SALES] < 160
band 4:160 [NORMAL SALES] < 320

104 Examples

2003 MicroStrategy, Inc.

3
BASIC FUNCTIONS

Introduction
These are basic mathematical functions like average, greatest,
least, maximum, minimum, and so on. They are not as
technically sophisticated as many of the other functions you
will see in this reference, but they are among the most
commonly used functions when creating a calculation.

2003 MicroStrategy, Inc.

105

Basic Functions

MicroStrategy Analytical Functions Reference

Average
Name
AVG

Information returned
The average (also known as arithmetic mean) of a group of
listed values.

Syntax
AVG <FP> (Fact) {~+} <FL>|TR|, where Fact is an array of
listed values for which the average is sought.

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Count
Name
COUNT

Information returned
The number of entries in a vector or list of values.

106 Average

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Syntax
COUNT <FP> (Fact) {~+} <FL>|TR|, where Fact is an array
of listed values.

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

First
Name
FIRST

Information returned
The first value in a sorted set of values.

Syntax
First <FP> (Fact) {-+}, where Fact is an array of listed values.
The Function Parameter is sort-by, where a user can define
what attributes to sort the data on. If no sort-by is defined,
then they are sorted by the values.

Database syntax for Oracle 9i and above


First = Min(#0) keep (dense_rank first order by #1)

2003 MicroStrategy, Inc.

First

107

Basic Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Geometric mean
Name
GEOMEAN

Information returned
Geometric mean of a range of positive values. For example,
the average growth rate for a given compound interest with
variable rates.

Syntax
GEOMEAN < > (Fact) {~+} <FL>|TR|, where Fact is an array
of values (y) whose geometric mean is sought.

Expression

Note
This function results in an invalid return if a data point in the
array is negative.

108 Geometric mean

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Greatest
Name
Greatest

Information returned
Greatest returns the largest value in the value list.

Syntax
Greatest(M1, M2, M3,), where M1, M2, and so on are
metrics. You cannot use facts in this function.

Function support
There is currently no database support for this function.

Last
Name
LAST

Information returned
The last value in a sorted set of values.

2003 MicroStrategy, Inc.

Greatest

109

Basic Functions

MicroStrategy Analytical Functions Reference

Syntax
Last <FP> (Fact) {-+}, where Fact is an array of listed values.
The Function Parameter is sort-by, where a user can define
what attributes to sort the data on. If no sort-by is defined,
then they are sorted by the values.

Database syntax for Oracle 9i and above


Last = Max(#0) keep (dense_rank last order by #1)

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Least
Name
Least

Information returned
Least returns the smallest value in the value list.

Syntax
Least(M1, M2, M3,), where M1, M2, and so on are metrics.
You cannot use facts in this function.

110 Least

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Function support
There is currently no database support for this function.

Maximum
Name
MAX

Information returned
The highest value in a vector or value list.

Syntax
MAX <FP> (Fact) {~+} <FL>|TR|, where Fact is a list of
values for which the maximum is sought.

Function support
See Appendix A: Database Support for MicroStrategy
Functionsfor a list of the databases that support this function.

Median
Name
MEDIAN

2003 MicroStrategy, Inc.

Maximum

111

Basic Functions

MicroStrategy Analytical Functions Reference

Information returned
The value in the middle of a set of listed values (half the
entries in the list are greater than the median, half are less).

Syntax
MEDIAN <FP> (Fact) {~+} <FL>|TR|, where Fact is an array
of data for which the median is sought.

Note
This function provides a location measure: the value returned
has a relative position with regard to other values in the array
(see also Mode).

Minimum
Name
MIN

Information returned
The lowest value in a given vector or value list.

Syntax
MIN <FP> (Fact) {~+} <FL>|TR|, where Fact is a list of values
for which the minimum is sought.

112 Minimum

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Mode
Name
MODE

Information returned
The value occurring most frequently in a given vector or list.

Syntax
MODE <FP> (Fact) {~+} <FL>|TR|, where Fact is a list of
values for which the mode is sought.

Note
This function provides a location measure: the value returned
has a relative position with regard to other values in the list
(see also Mean).

2003 MicroStrategy, Inc.

Mode

113

Basic Functions

MicroStrategy Analytical Functions Reference

Product
Name
PRODUCT

Information returned
The product of all values in a vector or list.

Syntax
PRODUCT <FP> (Fact) {~+} <FL>|TR| where Fact is a list of
values for which the product is sought.

114 Product

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Standard deviation (of a population)


Name
STDEVP

Information returned
The standard deviation of a set of values when an entire
population is provided as a set of arguments.1
1 The standard deviation shows how widely values in the population differ from the
mean.

Syntax
STDEVP < > (Fact) {~+} <FL>|TR|, where Fact is a set of
values (x) whose standard deviation is sought.

Expression

Notes

2003 MicroStrategy, Inc.

For this function, arguments correspond to an entire


population (as opposed to a population sample; see
Standard deviation of a sample).

When very large population samples are used, this


function and the Standard deviation of a sample function
return approximately equal results.

Standard deviation (of a population)

115

Basic Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Standard deviation (of a sample)


Name
STDEV

Information returned
Standard deviation of a group within a population, based on a
sample.1
1 The standard deviation of a group is an indicator of how widely values in the group

differ from the mean.

Syntax
STDEV < > (Fact) {~+} <FL>|TR|, where Fact is a set of
values (x) whose standard deviation is sought.

Expression

116 Standard deviation (of a sample)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Notes

In this function, arguments correspond to a population


sample (as opposed to the entire population; see
Standard deviation of a population).

When very large population samples are used, this


function and the Standard deviation of a population
function return approximately equal results.

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Sum
Name
SUM

Information returned
The sum of all values in a given vector or array of data.

Syntax
SUM <FP> (Fact) {~+} <FL>|TR|, where Fact is a value list
for which the total value or sum is sought.

2003 MicroStrategy, Inc.

Sum

117

Basic Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Variance of a population
Name
VARP

Information returned
Variance based on an entire population.

Syntax
VARP < > (Fact) {~+} <FL>|TR|, where Fact is the set of
values (x) whose variance is sought.

Expression

Note
For this function, arguments relate to an entire population
(as opposed to a population sample; see Variance of a
sample.

118 Variance of a population

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Basic Functions

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

Variance of a sample
Name
VAR

Information returned
Variance based on a population sample.

Syntax
VAR < > (Fact) {~+} <FL>|TR|, where Fact is the set of values
(x) whose variance is sought.

Expression

Note
Assume, when using this function, that arguments constitute
a population sample (as opposed to a entire population; see
Variance of a population).

2003 MicroStrategy, Inc.

Variance of a sample

119

Basic Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Database Support for MicroStrategy
Functions for a list of the databases that support this
function.

120 Variance of a sample

2003 MicroStrategy, Inc.

4
DATE FUNCTIONS

Introduction
This chapter describes the Date functions. For syntax
purposes, all date- and time-related functions are based on
only one parameter (date).
MicroStrategy 7i Analytical Engine does not
+ The
calculate date/time functions. Date/time functions for
which your database does not include SQL syntax
support cannot be calculated in your environment.

2003 MicroStrategy, Inc.

121

Date Functions

MicroStrategy Analytical Functions Reference

Current Date
Name
CurrentDate

Information returned
The current date as provided by the database timer.

* This function does not take input parameters.


Syntax
The table shows the format for Current date in each
certified database.

122 Current Date

Database

Syntax

DB2 UDB

CURRENT DATE

DataJoiner

CURRENT DATE

Informix

TODAY

Oracle 8i

SYSDATE

Oracle 9i

CURRENT DATE

Redbrick

CURRENT DATE

SQL Server

GETDATE(D)

Sybase

GETDATE(D)

Tandem

{fn CURDATE]

Teradata

CURRENT DATE

Access

NOW(D)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Day of the Month


Name
DayOfMonth

Information returned
The number corresponding tothe day of the month for a date
used as input. The return value is an integer between 1 and
31.

Syntax
The table shows the format for Day of the month in each
certified database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

DAY(D)

DataJoiner

DAY(D)

Informix

DAY(D)

Oracle

TO_CHAR, (D DD)

Redbrick

EXTRACT (DAY FROM D)

SQL Server

DATEPART(DAY, D)

Sybase

DATEPART(DAY, D)

Teradata

EXTRACT (DATE FROM D)

Access

DAY(D)

Day of the Month

123

Date Functions

MicroStrategy Analytical Functions Reference

Day of the Week


Name
DayOfWeek

Information returned
The number corresponding to the day of the week for a date
used as input. The return value is an integer between 1 and 7.

Syntax
The table shows the format for Day of the week in each
certified database.

124 Day of the Week

Database

Syntax

DB2 UDB

DAYOFWEEK(D)

DataJoiner

DAYOFWEEK(D)

Informix

TO_CHAR(D, %W)

Oracle

TO_CHAR, (D, D)

Redbrick

EXTRACT (WEEKDAY FROM D)

SQL Server

DATEPART(WEEKDAY, D)

Sybase

DATEPART(WEEKDAY, D)

Tandem

{fn DAYOFWEEK(D)}

Access

DATEPART(w, D)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Day of the Year


Name
DayOfYear

Information returned
The number corresponding to the day of the year for a date
used as input. The return value is an integer between 1 and
365.

Syntax
The table shows the format for Day of the year in each
certified database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

DAYOFYEAR(D)

DataJoiner

DAYOFYEAR(D)

Informix

date(D) -mdy(12, 31, year(D)-1)

Oracle

TO_CHAR (D, DDD)

Redbrick

EXTRACT(DAYOFYEAR FROM D)

SQL Server

DATEPART(DAYOFYEAR, D)

Sybase

DATEPART(DAYOFYEAR, D)

Teradata

cast(cast(D as date) -cast(extract(year from


D)-1 as charc(4)||-12-31 as date) as int)

Access

DATEPART(y, D)

Day of the Year

125

Date Functions

MicroStrategy Analytical Functions Reference

Week
Name
Week

Information returned
The number corresponding to the week of the year for a date
used as input. The return value is an integer between 1 and
54.

Syntax
The table shows the format for Week in each certified
database.

126 Week

Database

Syntax

DB2 UDB

WEEK(D)

DataJoiner

WEEK(D)

Oracle

TO_CHAR(D WW)

Redbrick

EXTRACT(WEEK FROM D)

SQL Server

DATEPART(WEEK, D)

Sybase

DATEPART(WEEK, D)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Month
Name
Month

Information returned
The number corresponding to the month of the year for a
date used as input. The return value is an integer between 1
and 12.

Syntax
The table shows the format for Month in each certified
database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

MONTH(D)

DataJoiner

MONTH(D)

Informix

MONTH(D)

Oracle

TO_CHAR(D, MM)

Redbrick

EXTRACT(MONTH FROM D)

SQL Server

DATEPART(MONTH, D)

Sybase

DATEPART(MONTH, D)

Tandem,

{fn MONTH(D)}

Teradata

EXTRACT (MONTH FROM D)

Access

MONTH(D)

Month

127

Date Functions

MicroStrategy Analytical Functions Reference

Quarter
Name
Quarter

Information returned
The number corresponding to the quarter of the year for a
date used as input. The return value is an integer between 1
and 4.

Syntax
The table shows the format for Quarter in each certified
database.

128 Quarter

Database

Syntax

DB2 UDB

QUARTER(D)

DataJoiner

QUARTER(D)

Informix

trunc((month(D)- 1)/3) + 1

Oracle

TO_CHAR(D, Q)

Redbrick

EXTRACT(QUARTER FROM D)

SQL Server

DATEPART(QUARTER, D)

Sybase

DATEPART(QUARTER, D)

Tandem,

{fn QUARTER(D)}

Teradata

((EXTRACT(MONTH FROM D)-1/3) + 1

Access

DATEPART(q, D)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Year
Name
Year

Information returned
The year of the input date.

Syntax
The table shows the format for Year in each certified
database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

YEAR(D)

DataJoiner

YEAR(D)

Informix

YEAR(D)

Oracle

TO_CHAR (D, YYYY)

Redbrick

EXTRACT(YEAR FROM D)

SQL Server

DATEPART(YEAR, D)

Sybase

DATEPART(YEAR, D)

Tandem,

{fn YEAR(D)}

Teradata

EXTRACT(YEAR FROM D)

Access

YEAR(D)

Year

129

Date Functions

MicroStrategy Analytical Functions Reference

Current Date and Time


Name
CurrentDateTime

Information returned
Current date and time as provided by the database timer.

Syntax
The table shows the format for Current date and time in
each certified database.

130 Current Date and Time

Database

Syntax

DB2 UDB 7.0

CURRENT TIMESTAMP

DataJoiner

CURRENT TIMESTAMP

Informix

CURRENT YEAR to FRACTION(3)

Oracle 8i

SYSDATE

Oracle 9i

CURRENT_TIMESTAMP

Redbrick

CURRENT_TIMESTAMP

SQL Server

GETDATE(D)

Sybase

GETDATE(D)

Tandem

{fn CURDATE}

Teradata

CURRENT_TIMESTAMP

Access

NOW(D)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Current Time
Name
CurrentTime

Information returned
The current time as provided by the database timer. This
function does not take input parameters.

Syntax
The table shows the format for Current time in each
certified database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

CURRENT TIME

DataJoiner

CURRENT TIME

Informix

CURRENT HOUR to FRACTION(3)

Oracle 8i

SYSDATE

Oracle 9i

CURRENT_TIMESTAMP

Redbrick

CURRENT_TIME

SQL Server

GETDATE(T)

Sybase

GETDATE(T)

Tandem

{fn CURTIME}

Teradata

CURRENT_TIME

Access

NOW(T)

Current Time

131

Date Functions

MicroStrategy Analytical Functions Reference

Hour
Name
Hour

Information returned
The integer portion of the value for the hour of the input
time.

Syntax
The table shows the format for Hour in each certified
database.

132 Hour

Database

Syntax

DB2 UDB

Hour(T)

DataJoiner

Hour(T)

Informix

to_char(T, %H)

Oracle

TO_CHAR(T, HH)

Redbrick

EXCTRACT(HOUR FROM T)

SQL Server

DATEPART(Hour, T)

Sybase

DATEPART(HOUR, T)

Teradata

EXTRACT(HOUR FROM T)

Access

DATEPART(h, T)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Minute
Name
Minute

Information returned
The integer portion of the value for the minute of the input
time.

Syntax
The table shows the format for Minute in each certified
database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

Minute(T)

DataJoiner

Minute(T)

IInformix

to_char(T, %M)

Oracle

TO_CHAR(T, MI)

Redbrick

EXCTRACT(MINUTE FROM T)

SQL Server

DATEPART(Minute, T)

Sybase

DATEPART(MINUTE, T)

Teradata

EXTRACT(MINUTE FROM T)

Access

DATEPART(m, T)

Minute

133

Date Functions

MicroStrategy Analytical Functions Reference

Second
Name
Second

Information returned
The integer portion of the value for the second of the input
time.

Syntax
The table shows the format for Second in each certified
database.

134 Second

Database

Syntax

DB2 UDB

Second(T)

DataJoiner

Second(T)

Informix

to_char(T, %S)

Oracle

TO_CHAR(T, SSI)

Redbrick

EXCTRACT(SECOND FROM D)

SQL Server

DATEPART(Second, T)

Sybase

DATEPART(SECOND, T)

Teradata

substring(cast(extract(second from T) as
char(10)) from 1 for 2)

Access

DATEPART(s, T)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Date Functions

Millisecond
Name
MilliSecond

Information returned
The integer portion of the value for the millisecond of the
input time.

Syntax
The table shows the format for Millisecond in each certified
database.

2003 MicroStrategy, Inc.

Database

Syntax

DB2 UDB

MicroSecond(T)/1000

DataJoiner

MicroSecond(T)/1000

Informix

to_char(T, %F3)

Redbrick

EXCTRACT(MILLISECOND FROM T)

SQL Server

DATEPART(Millisecond, T)

Sybase

DATEPART(MILLISECOND, T)

Teradata

substring(cast(extract(second from T) as
char(10)) from 4 for 3)

Millisecond

135

Date Functions

136 Millisecond

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

5
FINANCE FUNCTIONS

Introduction
In MicroStrategy 7i, all finance-related calculations are
performed by the engine, regardless of database
environment.

2003 MicroStrategy, Inc.

137

Finance Functions

MicroStrategy Analytical Functions Reference

Accrued interest
Name
ACCRINT

Information returned
Accrued amount on a security that pays periodic interest.

Syntax
ACCRINT <Par = 1000, Basis = 0> (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 date1

Rate is the annual coupon rate

Par is the par value

Frequency is the number of coupon payments per year2

Basis is the time-count basis to be used3

1 The

date, after issue date, on which the security is traded to the buyer
are as follows: annual payments = 1, semiannual payments = 2, quarterly
payments = 4
3 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:
2 Values

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in each year.
2 (actual/360)

138 Accrued interest

Assumes actual number of days in each month, 360


days in each year.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Basis value

Application

3 (actual/365)

Assumes actual number of days in each month, 365


days in each year.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

where

Ai = number of accrued days for the ith quasi-coupon


period within an odd period

NC = 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 = normal length, in days, of the ith quasi-coupon


period within an odd period

Notes

If Issue, FirstInterest, Settlement, or Frequency is not


an integer it is truncated to its integral component.

The engine returns an empty cell if


Issue, FirstInterest, or Settlement is not a valid date
Par 1000
Basis 0
Issue Settlement
Frequency is a value other than 1, 2, or 4

2003 MicroStrategy, Inc.

Accrued interest

139

Finance Functions

MicroStrategy Analytical Functions Reference

Accrued interest at maturity


Name
ACCRINTM

Information returned
Accrued amount on a security that pays periodic interest at
maturity.

Syntax
ACCRINTM <Par = 1000, Basis =0 > (Issue, Maturity,
Rate), where

Issue is the issue date

Maturity is the maturity date1

Rate is the annual coupon rate

Par is the par value

Basis is the time-count basis to be used2

1 The date

on which the coupon expires.


given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

2 The

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in each year.

140 Accrued interest at maturity

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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Expression

where
A = accrued time (for interest-at-maturity items, the value
used is the number of days from issue to maturity)
D = annual-yield basis

Notes

If Issue or Maturity is not an integer it is truncated to its


integral component.

The engine returns an empty cell if


Issue or Maturity is not a valid date
Rate 0
Par 1000
Basis 0

Amount received at maturity


Name
RECEIVED

Information returned
The amount received at maturity on a fully invested security.

2003 MicroStrategy, Inc.

Amount received at maturity

141

Finance Functions

MicroStrategy Analytical Functions Reference

Syntax
RECEIVED <Basis = 0> (Settlement, Maturity, Investment,
Discount), where

Settlement1 is the settlement date

Maturity2 is the date of maturity

Investment is the amount invested

Discount is the discount rate

Basis3 is the time-count basis to be used

The date, after issue, on which the security is sold.

2 The date on which the coupon expires.


3 The

given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

Where
B = number of days in a year (see Basis)
DIM = number of days between settlement to maturity

142 Amount received at maturity

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Notes

If Settlement or Maturity is not an integer it is truncated


to its integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Investment
Discount

Basis 0
Maturity Settlement

Coupon, number payable between settlement


and maturity
Name
COUPNUM

Information returned
The number of coupons payable between the settlement date
and maturity date, rounded up to the nearest whole coupon.

Syntax
COUPNUM <Basis = 0> (Settlement, Maturity,
Frequency), where

2003 MicroStrategy, Inc.

Settlement is the settlement date

Maturity is the maturity date

Frequency is the number of coupon payments per year

Coupon, number payable between settlement and maturity

Finance Functions

MicroStrategy Analytical Functions Reference

Basis is the time-count basis to be used

Notes

The number of days between milestones are computed


depending on the chosen day basis.

Coupon functions are defined against the maturity day,


depending on frequency.

Coupon date, next (after settlement)


Name
COUPNCD

Information returned
A number that represents the next coupon day after
settlement.

Syntax
COUPNCD <Basis = 0> (Settlement, Maturity, Frequency),
where

Settlement is the settlement date1

Maturity is the maturity date2

Frequency is the number of coupon payments per year3

Basis is the time-count basis to be used4

1 Date,

after issue, on which the security is traded.


Date on which the security expires.
3 Values are as follows:
annual payments = 1
semiannual payments = 2
2

144 Coupon date, next (after settlement)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

quarterly payments = 4
4

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Notes

If an argument is not an integer it is truncated to its


integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Frequency is a number other than 1, 2, or 4
Basis 0
Settlement Maturity

2003 MicroStrategy, Inc.

Coupon date, next (after settlement)

145

Finance Functions

MicroStrategy Analytical Functions Reference

Coupon date, previous (before settlement)


Name
COUPPCD

Information returned
A number that represents the coupon date before settlement
date.

Syntax
COUPPCD <Basis = 0> (Settlement, Maturity, Frequency),
where

Settlement is the settlement date1

Maturity is the maturity date2

Frequency is the number of payments per year3

Basis is the time-count basis to be used4

1 Date, after

issue, on which the security is traded.

2 Date on which the security expires.


3 Values are as follows:

annual payments = 1
semiannual payments = 2
quarterly payments = 4
4

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in each year.
2 (actual/360)

146 Coupon date, previous (before settlement)

Assumes actual number of days in each month, 360


days in each year.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Basis value

Application

3 (actual/365)

Assumes actual number of days in each month, 365


days in each year.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Notes

If an argument is not an integer it is truncated to its


integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Frequency has a value other than 1, 2, or 4
Basis 0
Settlement Maturity

Coupon period, beginning to settlement


Name
COUPDAYBS

Information returned
The number of days from the beginning of a coupon period to
settlement date.

Syntax
COUPDAYBS <Basis = 0> (Settlement, Maturity,
Frequency), where

2003 MicroStrategy, Inc.

Coupon period, beginning to settlement

147

Finance Functions

MicroStrategy Analytical Functions Reference

Settlement is the settlement date1

Maturity is the maturity date2

Frequency is the number of coupon payments per year3

Basis is the time-count basis to be used4

The date, after issue, on which the security is traded to the buyer.
The date on which the security expires.
3
Values are as follows:
annual payments = 1
semiannual payments = 2
quarterly payments = 4
2

4 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Notes

If an argument is not an integer it is truncated to its


integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Frequency is a number other than 1, 2, or 4
Basis 0
Settlement Maturity

148 Coupon period, beginning to settlement

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Coupon period, number of days with settlement


Name
COUPDAYS

Information returned
The number of days in the coupon period that contain the
settlement date.

Syntax
COUPDAYS <Basis = 0> (Settlement, Maturity,
Frequency), where

Settlement is the settlement date

Maturity is the maturity date

Frequency is the number of coupon payments per year

Basis is the time-count basis to be used

Notes

2003 MicroStrategy, Inc.

The number of days between milestones are computed


depending on the chosen day basis.

Coupon functions are defined against the maturity day,


depending on frequency.

Coupon period, number of days with settlement

149

Finance Functions

MicroStrategy Analytical Functions Reference

Coupon period, settlement to next coupon


Name
COUPDAYSNC

Information returned
The number of days from settlement to the next coupon date.

Syntax
COUPDAYSNC <Basis = 0> (Settlement, Maturity,
Frequency), where

Settlement is the settlement date1

Maturity is the maturity date2

Frequency is the number of coupon payments per year3

Basis is the time-count basis to be used4

1 The date,

after issue, on which the security is traded to the buyer.


The date on which the security expires.
3 Values are as follows:
annual payments = 1
semiannual payments = 2
quarterly payments = 4
2

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in each year.
2 (actual/360)

150 Coupon period, settlement to next coupon

Assumes actual number of days in each month, 360


days in each year.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Basis value

Application

3 (actual/365)

Assumes actual number of days in each month, 365


days in each year.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Notes

If an argument is not an integer it is truncated to its


integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Frequency is a number other than 1, 2, or 4
Basis 0
Settlement Maturity

Cumulative interest paid


Name
CUMIPMT

Information returned
The cumulative interest paid on a loan.

Syntax
CUMIPMT <Type = 0> (Rate, Nper, Pv, Start, End), where

2003 MicroStrategy, Inc.

Rate is the interest rate

Cumulative interest paid

151

Finance Functions

MicroStrategy Analytical Functions Reference

Nper is the total number of payment periods

Pv is the present loan value

Start is the first period in the calculation1

End is the last period in the calculation

Type is the timing of the payment

Payment-period counting begins with 1.

Notes

Consistency is important when specifying Rate and Nper:


for monthly payments on a four-year loan at an
annual interest rate of 12%, Rate = 12%/12; Nper =
4*12
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 to its integral component.

The engine returns an empty cell if


Rate

0, Nper

0, or Pv 0

Start < 1 or End < 1


Start > End
Type 0

152 Cumulative interest paid

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Cumulative principal paid


Name
CUMPRINC

Information returned
The cumulative principal paid on a loan.

Syntax
CUMPRINC <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 calculation1

End is the last period in the calculation

Type is the timing of the payment

1Payment-period counting begins

with 1.

Notes

Consistency is important when specifying Rate and Nper:


for monthly payments on a four-year loan at an
annual interest rate of 12%, Rate = 12%/12; Nper =
4*12
for annual payments on a four-year loan at an annual
interest rate of 12%, Rate = 12%; Nper = 4

2003 MicroStrategy, Inc.

If Nper, Star, End, or Type is not an integer, it is


truncated to its integral component.

Cumulative principal paid

153

Finance Functions

MicroStrategy Analytical Functions Reference

The engine returns an empty cell if


Rate

0, Nper

0, or Pv 0

Start< 1 or End < 1


Start > End
Type 0

Dollar price, converted from fraction to decimal


Name
DOLLARDE

Information returned
Converts a dollar price expressed as a fraction into a dollar
price expressed as a decimal number.

Syntax
DOLLARDE < > (FractionalDollar, Fraction)

Expression

100
= INT(price ) + price - INT( price ) *

fraction

Where

price = dollar value to be converted

fraction = fraction denominator value as an integer

154 Dollar price, converted from fraction to decimal

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Dollar price, converted from decimal to fraction


Name
DOLLARFR

Information returned
Converts a dollar price expressed as a decimal into a dollar
price expressed as a fraction.

Syntax
DOLLARFR < > (DecimalDollar, Fraction)

Expression
= INT( price ) +

[ price - INT(price )]
100 / fraction

Where

price = dollar value to be converted

fraction = fraction denominator value as an integer

Double-declining balance (asset depreciation)


Name
DDB

2003 MicroStrategy, Inc.

Dollar price, converted from decimal to fraction

155

Finance Functions

MicroStrategy Analytical Functions Reference

Information returned
The depreciation of an asset for a specified period, using the
double-declining-balance method.

Syntax
DDB <Factor = 2> (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
(Cost - Salvage) * Factor / Life

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.

Discount rate for a security


Name
DISC

156 Discount rate for a security

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Information returned
The discount rate on a security.

Syntax
DISC <Basis = 0> (Settlement, Maturity, Price,
Redemption), where

Settlement is the settlement date1

Maturity is the maturity date2

Price is the price per $100 of face value

Redemption is the redemption value per $100 of face


value

Basis is the time-count basis to be used3

1 The date,

after issue, on which the security is traded to the buyer.


The date on which the security expires.
3 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:
2

Basis value

Application

1 (actual/actual) Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

Where

2003 MicroStrategy, Inc.

Discount rate for a security

157

Finance Functions

MicroStrategy Analytical Functions Reference

B = number of days in a year (see Basis)

DMS = number of days between settlement and maturity

Notes

If Settlement or Maturity is not an integer it is truncated


to its integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
Price 0 or Redemption 0
Basis 0
Settlement Maturity

Duration
Name
DURATION

Information returned
The Macauley duration for an assumed par value of $100.
Duration is defined as the weighted average of the present
value of the cash flows and is used as a measure of a bond
prices response to changes in yield.

Syntax
DURATION <Basis = 0> (Settlement, Maturity,
CouponRate, YieldRate, Frequency), where

158 Duration

Settlement is the settlement date

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Maturity is the maturity date

CouponRate is the annual interest rate of the coupon

YieldRate is the annual yield

Frequency is the number of coupon payments per year

Basis is the time-count basis to be used

Expression

DSC

100

100 coupon

k - 1 + DSC
E
+

DSC
DSC

E
N -1+

k -1+

k =1

E
E
yld
yld
1 +

frequency 1 + frequency

frequency

1
=

frequency

100
100 coupon

DSC
DSC

N -1+

k -1+

k =1

E
E
yld
yld

1+
frequency 1 +

frequency
frequency

Where

DSC = number of days from settlement to next coupon


date

E = number of days in settlements coupon period

N = number of coupons from settlement to maturity

Effective annual interest rate


Name
EFFECT

Information returned
The effective annual interest rate on a given amount.

2003 MicroStrategy, Inc.

Effective annual interest rate

159

Finance Functions

MicroStrategy Analytical Functions Reference

Syntax
EFFECT < > (NominalRate, Npery), where

NominalRate is the nominal interest rate

Npery is the number of compounding periods per year

Expression

Notes

If Npery is not an integer it is truncated to its integral


component.

The engine returns an empty cell if


either argument is nonnumeric
NominalRate 0
Npery < 1

Fixed-declining balance (asset depreciation)


Name
DB

160 Fixed-declining balance (asset depreciation)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Information returned
The depreciation finance functions:accrued interest of an
asset for a specified period, using the fixed-declining-balance
method.

Syntax
DB <Month = 12> (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


depreciated1

Period is the period over which depreciation is calculated

Month is the number of months in the first year

1Life

is also referred to as the useful life of an asset.

Expression

To calculate depreciation over any given period:


(Cost - depreciation from previous periods) * Rate, where

rate = 1 - [(salvage / cost) (1 / life)]

To calculate depreciation for the first period:


Cost * Rate * Month /12

To calculate depreciation for the last period:


[(cost - total depreciation from previous periods) * rate *
(12 - month)] / 12

2003 MicroStrategy, Inc.

Fixed-declining balance (asset depreciation)

161

Finance Functions

MicroStrategy Analytical Functions Reference

Future value
Name
FV

Information returned
The future value of an investment based on periodic, constant
payments and a constant interest rate.

Syntax
FV <Type = 0> (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 period1

Pv is the present value (lump-sum amount) of future


payments2

Type indicates when payments are due

1 Typically, includes principal and interest, but no other fees or taxes.


2

If omitted, it is assumed to be 0 (zero).

Note

162 Future value

In all cases, disbursements (such as deposits) are


represented by negative numbers; funds received (such
as dividends) are represented by positive numbers.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Future value schedule


Name
FVSCHEDULE

Information returned
The future value of an initial principal after a series of
compound-interest rates are applied.

Usage
To calculate the future value of an investment that has a
variable or adjustable rate.

Syntax
FVSCHEDULE <Basis = 0 > (Values, PV), where

Values is a set of applicable interest rates

PV is the present value of the investment

Basis is the time-count basis to be used1

1 The

given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

2003 MicroStrategy, Inc.

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in each year.

2 (actual/360)

Assumes actual number of days in each month, 360


days in each year.

Future value schedule

163

Finance Functions

MicroStrategy Analytical Functions Reference

Basis value

Application

3 (actual/365)

Assumes actual number of days in each month, 365


days in each year.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Note
If Values is nonnumeric, the engine returns an empty cell.

Interest payment
Name
IPMT

Information returned
The interest payment for a given period1.
1 Based on

periodic, constant payments and a constant interest rate.

Syntax
IPMT < FV = 0, Type = 0 > (Rate, Period, Nperiod, PV),
where

164 Interest payment

Rate is the interest rate per period

Period is the period for which the interest payment is


sought2

Nperiod is the total number of payment periods

PV is the present value3

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

FV is the future value (also called cash balance) expected


after the last payment is made

Type indicates when payments are due

2
3

The valid range is from 1 to Nperiod.


The lump-sum value that a series of future payments has today.

Notes

For this function, consistency in the units used is


necessary:
assuming monthly payments on a four-year loan at
12% annual interest, Nperiod should be 4 * 12
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.

Interest rate
Name
INTRATE

Information returned
The interest rate for a fully invested security.

Syntax
INTRATE <Basis = 0> (Settlement, Maturity, Investment,
Redemption), where

2003 MicroStrategy, Inc.

Interest rate

165

Finance Functions

MicroStrategy Analytical Functions Reference

Settlement is the settlement date

Maturity is the maturity date

Investment is the amount invested in the security

Redemption is the amount actually received for the


security

Basis is the time-count basis to be used

Expression
redemption - investment B
=

DIM
investment

Where

redemption = amount actually received for the security

investment = amount invested in the security

B = number of days in a year, depending on year basis

DIM = number of days from settlement to maturity

Interest rate per period


Name
RATE

Information returned
The interest rate per period on a given annuity.

166 Interest rate per period

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Syntax
RATE <FV = 0, Type = 0, Guess = 0 > (Nperiod, Payment,
PV), where

Nperiod is the total number of payment periods

Payment is the payment made for each period1

PV is the present value of the annuity2

FV is the future value (also called cash balance) expected


after the last payment

Type indicates when payments are due

Guess is an estimate assumed to be close to the result


sought

1 Cannot change over the life of the annuity. Typically, includes principal and interest, but no other fees or taxes.
2 The total amount that a series of future payments is worth today.

Notes

For this function, consistency in the units used is


necessary:
assuming monthly payments on a four-year loan at
12% annual interest, Nperiod should be 4 * 12
assuming annual payments on a four-year loan at 12%
annual interest Nperiod should be 4

2003 MicroStrategy, Inc.

Interest rate per period

167

Finance Functions

MicroStrategy Analytical Functions Reference

Internal rate of return


Name
IRR

Information returned
The internal rate of return on a set of payments1.
1 The internal rate of return is the interest rate received

for an investment consisting of payments that occur periodically. These payments need not be even in value,
but they must occur at regular intervals (such as monthly, quarterly, or annually).

Syntax
IRR <Guess = 0.1> (Value) {~+} <FL>|TR|, where

Value is a vector or data array that contains numbers for


which the internal rate of return is sought

Guess is an estimate assumed to be close to the result


sought

Notes

168 Internal rate of return

Value 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.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Modified duration
Name
MDURATION

Information returned
Returns the modified Macauley duration1 for a security with
an assumed par value of $100.
1 the weighted average of present payments

Usage
This function is used as a measure of bond-price response to
variations in yield.

Syntax
MDURATION <Basis = 0> (Settlement, Maturity,
CouponRate, YieldRate, Frequency), where

Settlement is the settlement date1

Maturity is the date of maturity2

CouponRate is the annual interest rate of the coupon

YieldRate is the annual yield

Frequency is the number of coupon payments per year3

Basis is the time-count basis used4

1 Date,

after issue, on which the security is traded.


Date on which the security expires.
3 Values are as follows:
annual payments = 1
semiannual payments = 2
quarterly payments = 4
2

2003 MicroStrategy, Inc.

Modified duration

169

Finance Functions

MicroStrategy Analytical Functions Reference

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression
=

DURATION

yld
1+

frequency

Where

yld = security annual yield

frequency = number of coupon payments per year

Notes

If Settlement, Maturity, or Frequency is not an integer it


is truncated to its integral component.

The engine returns an empty cell if


either Settlement or Maturity is not a valid date
CouponRate < 0
YieldRate < 0
Frequency is a number other than 1, 2, or 4
Basis 0
Settlement Maturity

170 Modified duration

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Modified internal rate of return


Name
MIRR

Information returned
The modified internal rate of return on a set of periodic
payments.1
1 This function takes into consideration both the cost of investment and the interest
received on investment.

Syntax
MIRR < > (Values, FinancialRate, ReinvestRate), where

Values is vector or array containing a set of numbers2

FinancialRate is the interest rate paid

ReinvestRate is the interest rate received on reinvested


funds

2 Entries in this array can represent payments (negative values) or income (pos-

itive values) occurring at regular intervals.

Expression

Notes

2003 MicroStrategy, Inc.

If Values does not contain at least one positive entry


(income) and one negative entry (payments), the engine
returns an empty cell.

Modified internal rate of return

171

Finance Functions

MicroStrategy Analytical Functions Reference

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.

Net present value (of an investment)


Name
NPV

Information returned
The net present value of an investment.1
1

Based on a discount rate and a set of future payments (negative values) and income (positive values).

Syntax
NPV < > (Values, Rate) {~+} <FL>|TR|, where

Values is an array 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

172 Net present value (of an investment)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Notes

All entries in Values must be equally spaced in time, and


occur at the end of each period.

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, its must be added to the result of the function.

The primary differences between this function and the


Present Value (PV) function are that
PV allows fund flow to occur either at the beginning or
at the end of a period
PV fund-flow occurrences must be constant across the
life of the investment

See also Present value.

Nominal annual interest rate


Name
NOMINAL

Information returned
The nominal annual interest rate on an investment.1
1 Based on

2003 MicroStrategy, Inc.

the effective rate and the number of compounding periods per year.

Nominal annual interest rate

173

Finance Functions

MicroStrategy Analytical Functions Reference

Syntax
NOMINAL < > (EffectiveRate, Npery), where

EffectiveRate is the effective interest rate

Npery is the number of compounding periods per year

Expression

Notes

If Npery is not an integer it is truncated to its integral


component.

The engine returns an empty cell if


either argument is nonnumeric
EffectiveRate 0
Npery < 1

Number of investment periods


Name
NPER

Information returned
The number of periods for an investment.1
1 Based on

174 Number of investment periods

periodic, constant payments and a constant interest rate.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Syntax
NPER <Type = 0> (Rate, Pmt, PV, FV), where

Rate is the internal rate for each period

Pmt is the amount paid each period2

PV is the present value of a series of future payments3

FV is the value that remains after the last payment is


made

Type is a number that indicates when payments are due

2
3

Typically, includes principal and interest, but no other fees or taxes.


If omitted, it is assumed to be 0 (zero).

Odd-first-period price
Name
ODDFPRICE

Information returned
The price per $100 face value of a security having an odd
(short or long) first period.

Syntax
ODDFPRICE <Basis = 0> (Settlement, Maturity, Issue,
FirstCoupon, CouponRate, YieldRate, Redemption,
Frequency), where

2003 MicroStrategy, Inc.

Settlement is the settlement date

Maturity is the maturity date

Issue is the issue date

Odd-first-period price

175

Finance Functions

MicroStrategy Analytical Functions Reference

FirstCoupon is the first-coupon date

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

Basis is the time-count basis to be used

Expression
Odd Short First Coupon

redemption
=
DSC

N -1+

E
yld

1 +
frequency



rate
DFC

100
frequency
E
+
DSC


E
yld

1+
frequency



rate
100
N
frequency
+
DSC


k -1+

k =2

E
yld
1 +


frequency

rate
A
- 100


frequency E

Where

A = number of days from beginning of coupon period to


settlement date (accrued days)

DSC = number of days from settlement to next coupon


date

DFC = number of days from the beginning of odd first


coupon to first coupon date

E = number of days in coupon period

N = 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

redemption
=
DSC

N +N q +

E
yld

1+

frequency

176 Odd-first-period price


NC DC
rate
i
100
rate

100

frequency
NL N
frequency
i =1 i +
+
DSC
DSC

N +

k -N q +


q E k = 2

E
yld
yld

1+

1+

frequency
frequency


NC
rate
Ai
- 100


frequency
NLi
i =1

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Where

Ai = number of days from beginning of the ith


quasi-coupon period within odd period

DCi = Number of days from date to first quasi-coupon


(i=1) or number of days in quasi-coupons (i=2,..., i=NC)

DSC = Number of days from settlement to next coupon


date

E = Number of days in coupon period

N = 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 = 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 = Normal length in days of the full ith quasi-coupon


period within odd period

Nq = Number of whole quasi-coupon periods between


settlement date and first coupon

Odd-first-period yield
Name
ODDFYIELD

Information returned
The yield of a security that has an odd (either long or short)
first period.

2003 MicroStrategy, Inc.

Odd-first-period yield

177

Finance Functions

MicroStrategy Analytical Functions Reference

Syntax
ODDFYIELD <Basis = 0> (Settlement, Maturity, Issue,
FirstCoupon, CouponRate, Price, Redemption,
Frequency), where

Settlement is the settlement date1

Maturity is the maturity date2

Issue is the issue date

FirstCoupon is the first-coupon date

Rate is the interest rate

Pr is the price

Redemption is the redemption value per $100 of face


value

Frequency is the number of payments per year3

Basis is the time-count basis to be used4

1 Date, after

issue, on which the security is traded.

2 Date on which the security expires.


3

Values are as follows:


annual payments = 1
semiannual payments = 2
quarterly payments = 4
4

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

178 Odd-first-period yield

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Notes

If Settlement, Maturity, Issue, or FirstCoupon is not an


integer it is truncated to its integral component.

The engine returns an empty cell if


Settlement, Maturity, Issue, or FirstCoupon is not a
valid date
Rate < 0
Pr 0
Basis 0
The following date-related condition is not satisfied:
Maturity > FirstCoupon > Settlement > Issue

Odd-last-period price
Name
ODDLPRICE

Information returned
The price per $100 face value of a security having an odd
(short or long) last period.

Syntax
ODDLPRICE <Basis = 0> (Settlement, Maturity,
LastInterest, CouponRate, YieldRate, Redemption,
Frequency), where

2003 MicroStrategy, Inc.

Settlement is the settlement date

Maturity is the maturity date

LastInterest is the last date on which interest is accrued


Odd-last-period price

179

Finance Functions

MicroStrategy Analytical Functions Reference

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

Basis is the time-count basis to be used

Expression
Odd Last Coupon with One Redemption or Less from
Settlement Date

NC DC 100 rate
i

redemption +

frequency NC

NL
i

i =1

Ai
-
=

NC
NLi

DSC i
yld
i =1

1+


i =1 NLi frequency

100 rate

frequency

Where

180 Odd-last-period price

Ai = Number of accrued days for the ith quasi-coupon


period within odd period counting forward from last
interest date before redemption

DCi = Number of days counted in each ith quasi-coupon


period as delimited by the length of the actual coupon
period

NC = 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 = Normal length in days of the ith quasi-coupon


period within odd coupon period

DSCi = 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.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Odd-last-period yield
Name
ODDLYIELD

Information returned
The yield of a security that has an odd (short or long) last
period.

Syntax
ODDLYIELD <Basis = 0> (Settlement, Maturity,
LastInterest, CouponRate, Price, Redemption,
Frequency), where

2003 MicroStrategy, Inc.

Settlement is the settlement date

Maturity is the maturity date

LastInterest is the 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

Basis is the time-count basis to be used

Odd-last-period yield

181

Finance Functions

MicroStrategy Analytical Functions Reference

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

Payment
Name
PMT

Information returned
The payment cost on a loan.1
1 Based on

182 Payment

constant payments and a constant interest rate.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Syntax
PMT <FV = 0, Type = 0> (Rate, Nper, PV), where

Rate is the interest rate

Nper is the number of payments

PV is the present value of the loan2

FV is the future value of the loan3

Type is a value that indicates when payment is due

2
3

Also referred to as principal, this the current value of a set of future payments.
The balance to be attained once all payments are made.

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:

to calculate monthly payments on a four-year loan at


12% annual interest, Rate should be 12%/12, Nper
should be 4*12

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.

Present value
Name
PV

2003 MicroStrategy, Inc.

Present value

183

Finance Functions

MicroStrategy Analytical Functions Reference

Information returned
Returns the present value of an investment

Syntax
PV <Type = 0> (Rate, Nper, Pmt, FV), where

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

Type is a value that indicates when payment is due

Expression
If rate == 0

Else

Price at maturity
Name
PRICEMAT

184 Price at maturity

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Information returned
The price, per $100 of face value, on a security that pays
interest at maturity.

Syntax
PRICEMAT <Basis = 0> (Settlement, Maturity, Issue,
CouponRate, YieldRate), where

Settlement is the settlement date1

Maturity is the maturity date2

Issue is the issue date3

CouponRate is the interest rate on the date of issue

YieldRate is the annual yield

Basis is the time-count basis to be used4

1 Date, after

the issue date, on which the security is traded.

2 Date on which the security expires.


3 Expressed as a serial date
4

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

2003 MicroStrategy, Inc.

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Price at maturity

185

Finance Functions

MicroStrategy Analytical Functions Reference

Expression

Where

B = number of days in a year (see Basis)

DSM = number of days from settlement to maturity

DIM = number of days from issue to maturity

A = number of days from issue to settlement

Notes

If Settlement, Maturity, or Issue is not an integer it is


truncated to its integral component.

The engine returns an empty cell if


Settlement, Maturity, or Issue is not a valid date
Rate < 0 or Yield < 0
Basis 0
Settlement Maturity

Price, discounted
Name
PRICEDISC

Information returned
The price per $100 face value on a discounted security.
186 Price, discounted

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Syntax
PRICEDISC <Basis = 0> (Settlement, Maturity, DiscRate,
Redemption), where

Settlement is the settlement date1

Maturity is the maturity date2

DiscRate is the discount rate

Redemption is the redemption value per $100 of face


value

Basis is the time-count basis to be used3

1 The date, after issue, on

which the security is traded.


The date on which the security expires.
3 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:
2

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

Where

2003 MicroStrategy, Inc.

B = number of days in a year (see Basis)

DSM = number of days from settlement to maturity

Price, discounted

187

Finance Functions

MicroStrategy Analytical Functions Reference

Notes

If Settlement or Maturity is not an integer it is truncated


to its integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
DiscRate 0 or Redemption 0
Basis 0
Settlement Maturity

Price per $100 face value


Name
PRICE

Information returned
The price, per $100 face value, on a security that pays
periodic interest.

Syntax
PRICE <Basis = 0> (Settlement, Maturity, CouponRate,
YieldRate, Redemption, Frequency), where

188 Price per $100 face value

Settlement is the settlement date1

Maturity is the maturity date2

CouponRate is the annual interest rate

YieldRate is the annual yield

Redemption is the redemption value per $100 of face


value
2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Frequency is the number of payments per year3

Basis is the time-count basis to be used4

Finance Functions

Date, after issue, on which the security is traded.

2 Date on which the security expires.


3

Values are as follows:


annual payments = 1
semiannual payments = 2
quarterly payments = 4
4 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

Where

2003 MicroStrategy, Inc.

DSC = number of days from settlement to next coupon


date

E = number of days in the coupon period in which the


settlement date falls

N = number of coupons payable between the settlement


date and the redemption date

A = number of days from the beginning of the coupon


period to settlement date

Price per $100 face value

189

Finance Functions

MicroStrategy Analytical Functions Reference

Notes

If Settlement, Maturity, or Frequency is not an integer it


is truncated to its integral component.

The engine returns an empty cell if


Settlement or Maturity is not a valid date
CouponRate < 0 or YieldRate < 0
Redemption 0
Frequency has a value other than 1, 2, or 4
Basis 0
Settlement Maturity

Principle payment
Name
PPMT

Information returned
The payment on the principle for an investment for one given
period.

Syntax
PPMT <Type = 0> (Rate, Per, Nper, PV, FV), where

190 Principle payment

Rate is the interest rate

Per is the period desired

Nper is the number of payments

PV is the present value of the loan

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

FV is the future value of the loan

Type is a value that indicates when payment is due

Expression
PPMT i=PMT - IPMT i
Where

i = period desired

Straight-line depreciation
Name
SLN

Information returned
The straight-line depreciation of an asset over a given period.

Syntax
SLN < > (Cost, Salvage, Life), where

Cost is the initial cost of the asset

Salvage is the residual value at the end of the estimated


life span1

Life is the number of periods over which the asset is being


depreciated2

1 Also called the

2 Also called the

2003 MicroStrategy, Inc.

salvaged value of an asset.


useful life of an asset.

Straight-line depreciation

191

Finance Functions

MicroStrategy Analytical Functions Reference

Sum of years digits depreciation


Name
SYD

Information returned
The sum of years digits depreciation of an asset over a
specified period.

Syntax
SYD < > (Cost, Salvage, Life, Period), where

Cost is the initial cost

Salvage is the residual value at the end of the estimated


life span1

Life is the number of periods over which the asset is being


depreciated2

Period is the depreciation period3

1 Also called the

salvaged value of an asset.


useful life of an asset.
3 Must have the same number of units as life.
2 Also called the

Expression

192 Sum of years digits depreciation

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

T-bill equity
Name
TBILLEQ

Information returned
The bond-equivalent yield of a Treasury bill.

Syntax
TBILLEQ < > (Settlement, Materity, Discount), where

Settlement is the settlement date

Maturity is the maturity date

Discount is the discount rate

Expression
=

(365 rate )
360

- rate (DSM )

Where

2003 MicroStrategy, Inc.

DSM = number of days between settlement and maturity


on 360=day basis

T-bill equity

193

Finance Functions

MicroStrategy Analytical Functions Reference

T-bill price
Name
TBILLPRICE

Information returned
The price of a treasury bill per $100 of face value.

Syntax
TBILLPRICE < > (Settlement, Maturity, Discount), where

Settlement is the settlement date1

Maturity is the maturity date2

Discount is the discount rate

1 The date, after issue, on

which the treasury bill is purchased.


bill expires.

2 The date on which the treasury

Expression

Where DSM = number of days from settlement to maturity3.


3 Excludes any maturity date that is

more than one calendar year past Settlement.

Notes

194 T-bill price

If Settlement or Maturity is not an integer it is truncated


to its integral component.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

The engine returns an empty cell if


either Settlement or Maturity is not a valid date
Discount

Settlement > Maturity


Maturity is more than one year after Settlement

T-bill yield
Name
TBILLYIELD

Information returned
The yield of a treasury bill.

Syntax
TBILLYIELD < > (Settlement, Maturity, Price), where

Settlement is the settlement date1

Maturity is the maturity date2

Price is the price per $100 of face value

1 The date

on which the treasury bill is purchased.


bill expires.

2 The date on which the treasury

Expression

Where DSM = number of days from settlement to maturity.3

2003 MicroStrategy, Inc.

T-bill yield

195

Finance Functions

MicroStrategy Analytical Functions Reference

3 Excludes any maturity date that is more than one calendar year past Settlement.

Notes

If Settlement or Maturity is not an integer it is truncated


to its integral component.

The engine returns an empty cell if


either Settlement or Maturity is not a valid date
Price

Settlement > Maturity


Maturity is more than one year after Settlement

Variable declining balance


Name
VDB

Information returned
The depreciation of an asset over a specified period.1
1Includes partial periods.

Syntax
VDB <Factor = 2> (Cost, Salvage, Life, Period), where

196 Variable declining balance

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

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Period is the first period for which depreciation is


calculated2

Factor is the rate at which balance declines

Finance Functions

Must use the same units as Life.

Note
All values must be positive.

Yield
Name
YIELD

Information returned
The yield on a security that pays periodic interest.

Syntax
YIELD <Basis = 0> (Settlement, Maturity, CouponRate,
Price, Redemption, Frequency), where

2003 MicroStrategy, Inc.

Settlement is the settlement date1

Maturity is the maturity date2

CouponRate is the annual interest rate

Price is the price per $100 of face value

Redemption is the redemption value per $100 of face


value

Frequency represents the number of payments per year3

Yield

197

Finance Functions

MicroStrategy Analytical Functions Reference

Basis is the time-count basis to be used4

The date on which the treasury bill is purchased.


bill expires.
3
Values are as follows:
annual payments = 1
semiannual payments = 2
quarterly payments = 4
2 The date on which the treasury

4 The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Expression

If there is one period (or less) until Redemption, this


function is calculated as follows:

Where
A = number of days from the beginning of the period
to Settlement
DSR = number of days from Settlement to
Redemption
E = number of days in a period

198 Yield

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).

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Notes

If Settlement, Maturity, or Frequency is not an integer it


is truncated to its integral component.

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

Yield at maturity
Name
YIELDMAT

Information returned
Annual yield on a security that pays interest at maturity.

Syntax
YIELDMAT < Basis = 0 > (Settlement, Maturity, Issue,
Rate, Price), where

2003 MicroStrategy, Inc.

Settlement is the settlement date1

Maturity is the date of maturity2

Issue is the issue date

Rate is the annual coupon rate

Price is the price per $100 of face value

Basis is the time-count basis to be used3

Yield at maturity

199

Finance Functions

MicroStrategy Analytical Functions Reference

The date, after issue, on which the security is traded.

2
The date on which the coupon expires.
3

The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Notes

If Settlement, Maturity, or Issue is not an integer, it is


truncated to its integral component.

The engine returns an empty cell if


Rate < 0
Price 0
Basis 0
Settlement Maturity

200 Yield at maturity

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Finance Functions

Yield on a discounted security


Name
YIELDDISC

Information returned
The annual yield on a discounted security.

Syntax
YIELDDISC <Basis = 0> (Settlement, Maturity, Price,
Redemption), where

Settlement is the settlement date1

Maturity is the maturity date2

Price is the price per $100 of face value

Redemption is the redemption value per $100 of face


value

Basis is the time-count basis to be used3

1 The date

on which the treasury bill is purchased.


bill expires.
3
The given value for Basis in the syntax for this function is 0 [used by American
agencies, assumes 30-day months and 360-day years (30/360)]. Other applicable
values for this parameters are as follows:
2 The date on which the treasury

2003 MicroStrategy, Inc.

Basis value

Application

1 (actual/actual)

Assumes actual number of days in each month,


actual number of days in 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.

4 (30/60)

Used by European agencies, assumes the same


values as 0 for American institutions.

Yield on a discounted security

201

Finance Functions

MicroStrategy Analytical Functions Reference

Notes

If Settlement or Maturity is not an integer it is truncated


to its integral component.

The engine returns an empty cell if


either Settlement or Maturity is not a valid date
Price

0 or Redemption 0

Basis 0
Maturity Settlement

202 Yield on a discounted security

2003 MicroStrategy, Inc.

6
INTERNAL FUNCTIONS

Introduction
Internal functions include Pass-through functions that are
MicroStrategy specific, Case functions, and some others that
are for MicroStrategy internal use only. Pass-through and
Case functions are detailed in the following sections. The
Intersect, Intersectln, and Tuple functions cannot be used;
validation fails if any of these is selected.

Pass-through functions
In MicroStrategy 7i, Pass-through functions are used to:

2003 MicroStrategy, Inc.

access and apply certain capabilities provided by the


Relational Database Management System (RDBMS).

customize queries by replacing available predefined


functions of the same type.

Pass-through functions

203

Internal Functions

MicroStrategy Analytical Functions Reference

Pass-through functions are implemented by means of Apply


statements, using the Fact Editor, the Attribute Editor, the
Filter Editor, or the Metric Editor as a vehicle to access the
Relational Database Management System (RDBMS). They
are available in five types, as shown in the table that follows.
Apply statement

Expression replaced

ApplySimple

Simple operators (for example, arithmetic


operators)

ApplyAgg

Basic functions (for example, Sum, Max)

ApplyOLAP

OLAP functions (for example, Rank)

ApplyComparison

Comparison operators (for example, <, Like,


In)

ApplyLogic

Logic operators (for example And, Or)

For more information on pass-through functions, see the


MicroStrategy 7i Advanced Reporting Guide.

Pass-through function syntax and usage


The table that follows lists the usage and shows application
examples for each of the Apply statements listed above.
Apply
statement
ApplySimple()

Usage

Application example

To insert database-specific
functions and simple operators
directly into the SQL. Accepts facts,
attributes, and metrics as input.

Attribute:
ApplySimple(Datediff(YY,#0,getdate(
)), [BIRTH_DATE]), in which
[BIRTH_DATE] is an attribute
ApplySimple(Months_between(sysd
ate,#0),[CURRENT_DT]) in which
[CURRENT_DT] is an attribute
Fact:
ApplySimple(Count(#0),[UNIT_CO
ST]), in which [UNIT_COST] is a fact
Filter:
ApplySimple(Stdev(#0),[CUR TRN
DT])>0

204 Pass-through functions

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Apply
statement

Usage

Internal Functions

Application example
Compound metric:
ApplySimple(Greatest(#0,#1,#2),
Metric_1, Metric_2,Metric_3)

ApplyAgg()

To define simple metrics or facts by


using database-specific group-value
functions1. Accepts facts, attributes,
and metrics as input.

Simple metric:

ApplyLogic()

To define custom filters. Accepts


logic (Boolean) values as input.

ApplyLogic(#0 and #1,


Year@ID>1999, Month@ID>199901)

ApplyComparis
on()

To define custom filters. Accepts


ApplyComparison(#0 in (Select
facts, attributes, and metrics as input. market_nbr from Lookup_Market,
where region=1), Market@ID)

ApplyAgg(Regrsxx(#0,#1), [Fact 1],


[Fact 2],
{~+} (this metric has dimensionality to
specify level, filtering, and so on)

ApplyComparison(#0 > 1999 and #1


>199901, Year@ID, Month@ID)
Self-adaptive metric:
Given:
two columns, [Column 1] and
[Column 2], from two different tables
(Fact Table 1 and Fact Table 2)
having different keys.
Column 1 and Column 2 represent
the same fact
A fact with two forms can be created,
as follows:
[Fact] with Form 1 =
ApplySimple(Sum(#0), [Column 1],
Form 2 = ApplySImple (Count(#0),
[Column 2], in which Form 1 comes
from Fact Table 1, and Form 2 comes
from Fact Table 2. A metric can then
be created, having the following
definition:
ApplyAgg(#0,[Fact]) {~+}
The correct group-value function for
this metric depends on the table
used.
ApplyOLAP()

2003 MicroStrategy, Inc.

To define compound metrics. Used


with database-specific OLAP
functions1 (such as Rank()). Accepts
only metrics as input.

ApplyOLAP(RunningSlope(#0,#1),
[Metric 1], [Metric 2]

Pass-through functions

205

Internal Functions

MicroStrategy Analytical Functions Reference

1 In most cases,

these values are not recognized as MicroStrategy 7i objects.

Case
Name
CASE

Information returned
Values depending on the evaluation of multiple conditions.

Syntax
CASE (condition1, results1, condition2, results2,
...conditionN, resultsN, resultsX), where

condition1 is the first condition to evaluate

results1 is the information to return if the first condition


is true

condition2 is the second condition to evaluate

results2 is the information to return if the second


condition is true

conditionN is the next condition to evaluate

resultsN is the information to return if the corresponding


condition is true

resultsX is the information to return if none of the other


conditions are true

Example
CASE (A=2, T, B>5, U, V)

206 Case

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Internal Functions

When A=2, return T; when B>5, return U; otherwise return


V.

Note
You must drag and drop all arguments onto the editor. If you
type any arguments the function will not validate.

Case Value
Name
CASEV

Information returned
Values depending on whether the given condition is true.

Syntax
CASEV (V, V1, E1, V2, E2, ..., Vn, En, En+1), where

2003 MicroStrategy, Inc.

V is the initial agreement or metric

V1 is the first value to be evaluated

E1 is the result if the first value is true

V2 is the second value to be evaluated

E2 is the result if the second value is true

Vn is the next value to be evaluated

En is the result if the corresponding value is true

En+1 is the result if none of the other values are true

Case Value

207

Internal Functions

MicroStrategy Analytical Functions Reference

Note
The metric or agreement in the CASEV expresssion 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. Therefore it is best if you wrap the metric
or agreement in the integer function; for example,
CASEV(int(M1), 2, A,...).

Expression
CASEV (M1, 2, a, 3, b, 4, c, d)
When M1=2, return a; when M1=3 return b; when M1=4
return c; otherwise return d. All values are compared to the
initial agreement or metric.

208 Case Value

2003 MicroStrategy, Inc.

7
MATHEMATICAL FUNCTIONS

Introduction
The way in which the system flags invalid entries for a given
function depends on the database being used. Error
conditions are flagged as described below.

2003 MicroStrategy, Inc.

If the database supports the calculation being performed,


the error condition is reflected as a GUI message.

If the calculation is performed by the MicroStrategy 7i


engine, the error condition causes an empty cell to be
returned.

209

Mathematical Functions

MicroStrategy Analytical Functions Reference

Absolute value
Name
ABS

Information returned
The absolute value of a given numeric expression.1
1 The absolute value of a number is

that number without a sign.

Syntax
ABS < > (Number), where Number is a real number whose
absolute value is sought.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Arc Cosine
Name
ACOS

Information returned
The arc cosine of a given angle1 (the angle is in radians2, the
range is 0-to-p).

210 Absolute value

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

1
2

Mathematical Functions

Arc cosine is the angle whose cosine is the number.


To convert a value from radians to degrees, multiply by 180/p.

Syntax
ACOS < > (Number), where Number is the value of the
cosine of the angle sought (this value must be between -1 and
1)

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Arc Sine
Name
ASIN

Information returned
The arcsine of a given number1 (the angle is in radians2, the
range is -p/2 to p/2).
1 Arcsine

is the angle whose sine is the number.


by 180/p.

2 To convert radians to degrees, multiply

Syntax
ASIN < > (Number), where Number is the value of the sine of
the angle sought (this value must be between -1 and 1)

2003 MicroStrategy, Inc.

Arc Sine

211

Mathematical Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Arc Tangent
Name
ATAN

Information returned
The arctangent of a given number1 (the angle is in radians2,
the range is p/2 to -p/2).
1 Arctangent is the angle whose tangent is the number.

2 To convert the result from radians to degrees, multiply by 180/p.

Syntax
ATAN < > (Number), where Number is the tangent of the
angle sought.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

212 Arc Tangent

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Arc Tangent 2
Name
ATAN2

Information returned
The approximate value of the arctangent of a given number
expresssed as the ratio of two input values (the angle is in
radians1, the range is p/2 to -p/2).
1 To convert the result from radians

to degrees, multiply by 180/p.

Syntax
ATAN 2< > (x_num, y_num), where x_num and y_num are
two values whose ratio is the tangent of the angle sought.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Arc Tangent 2

213

Mathematical Functions

MicroStrategy Analytical Functions Reference

Ceiling value
Name
CEILING

Information returned
The smallest integer greater than or equal to a given numeric
expression. (see also Floor value).

Usage
Ceiling calculations are called for in situations in which
results are expressed as specified units of measurement (for
example, to avoid price returns at the penny level, CEILING
could be used on a product priced at $4.42 to round up the
figures to the nearest nickel).

Syntax
CEILING < > (Number), where Number is the value to be
rounded up

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

214 Ceiling value

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Combination
Name
COMBINE

Information returned
The number of possible combinations for a given number of
items selected as a group from a set.1
1 In

combination calculations, the internal order of the items selected does not affect the return (as opposed to the case in a permutation, in which the order of the
items selected does affect the return; see also Permutation).

Syntax
COMBINE < > (Number, Number_Chosen), where

Number is the number of items in a set

Number_Chosen is the number of items selected for each


combination

Expression
the expression that follows, Number = n;
* InNumber_Chosen
= k,

Where

2003 MicroStrategy, Inc.

Combination

215

Mathematical Functions

MicroStrategy Analytical Functions Reference

Notes

If an argument is not an integer it is truncated to its


integral component.

This function returns an error value if


either argument is nonnumeric
n< 0
k<0
nk

Cosine
Name
COS

Information returned
The cosine of a given angle.

Syntax
COS < > (Number), where Number is the angle, in radians1,
for which the value of the cosine is sought.
1 To convert the

result from radians to degrees, multiply by 180/p.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

216 Cosine

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Cosine, hyperbolic
Name
COSH

Information returned
The hyperbolic cosine of a number.

Syntax
COSH < > (Number), where Number is the angle, in
radians1, for which the value of the hyperbolic cosine is
sought.
1 To convert radians

to degrees, multiply by 180/p.

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Cosine, hyperbolic

217

Mathematical Functions

MicroStrategy Analytical Functions Reference

Degrees (conversion to)


Name
DEGREES

Information returned
The value of an angle converted from radians to degrees.

Syntax
DEGREES < > (Angle), where Angle is the angle, in radians,
to be converted.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Exponent
Name
EXP

Information returned
e to the power of the number given.1
1

218 Degrees (conversion to)

e = 2.71828182845904 is the base of natural logarithms.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Syntax
EXP < > (Number), where Number is the power to which e is
raised.

Note
e is the inverse of ln, the natural logarithm of a number.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Factorial
Name
FACTORIAL

Information returned
The factorial of an integer n. This is written as n!, and is n *
n-1 * ... *2 * 1. In particular, 0! = 1.

Example
FACTORIAL(5)
returns 120, which is 5*4*3*2*1=120.

2003 MicroStrategy, Inc.

Factorial

219

Mathematical Functions

MicroStrategy Analytical Functions Reference

Syntax
FACTORIAL(Number), where Number is an integer.

Floor value
Name
FLOOR

Information returned
The largest integer less than or equal to a given numeric
expression. (see also Ceiling value).

Syntax
FLOOR < > (Number), where Number is the value to be
rounded down

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Integer
Name
INT

220 Floor value

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Information returned
A given non integer value rounded off to the nearest integer.

Syntax
INT < > (Number), where Number is a real number to be
rounded off.1
1 The expression [Number - INT(Number)] can be used to obtain the decimal
part of a non integer as a return.

Logarithm
Name
LOG

Information returned
The logarithm of a given number in a specified base.

Syntax
LOG < > (Number, Base), where

2003 MicroStrategy, Inc.

Number is a positive real number for which the logarithm


is sought

Base is the base of the logarithm (if the base is not


identified, it is assumed to be 10; see Logarithm, base 10)

Logarithm

221

Mathematical Functions

MicroStrategy Analytical Functions Reference

Logarithm, base 10
Name
LOG10

Information returned
The base-10 logarithm of a given number.

Syntax
LOG10 < > (Number), where Number is a positive real
number for which the base-10 logarithm is sought

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Logarithm, natural
Name
LN

Information returned
The natural logarithm of a given number.1
1

222 Logarithm, base 10

The base for natural logarithms is e (e = 2.71828182845904).

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Syntax
LN < > (Number), where Number is a positive real number
for which the natural logarithm is sought.2
2

Ln is the inverse of the EXP (exponential) function (see also Exponential)

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Logarithm, natural

223

Mathematical Functions

MicroStrategy Analytical Functions Reference

Power
Name
POWER

Information returned
The value of an input numeric expression raised to a given
power.

Syntax
POWER < > (Number, Power), where

Number is the base number1

Power is the exponent to which Number is raised

1 All real numbers are valid

for this function.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

224 Power

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Quotient
Name
QUOTIENT

Information returned
The integral portion of a division.

Usage
This function is used to discard the remainder portion of a
division.

Syntax
QUOTIENT < > (numerator, denominator), where

numerator is the dividend

denominator is the divisor

Radians (conversion to)


Name
RADIANS

Information returned
The value of an angle converted from degrees to radians.

2003 MicroStrategy, Inc.

Quotient

225

Mathematical Functions

MicroStrategy Analytical Functions Reference

Syntax
RADIANS < > (Number), where Number is the value to be
converted from degrees to radians.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Random number (between two values)


Name
RANDBETWEEN

Information returned
A random number that falls between two given values. A
different number is returned each time the function is run.

Syntax
RANDBETWEEN < > (bottom, top), where:

bottom is the lower of the two input values

top is the higher of the two input values

226 Random number (between two values)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Sine
Name
SIN

Information returned
The sine of a given angle.

Syntax
SIN < > (Number), where Number is the value, in radians,
whose sine is sought.1
1 Multiplying the argument by p/180 converts an angle from degrees to

radians.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Sine, hyperbolic
Name
SINH

Information returned
The hyperbolic sine of a given angle.

2003 MicroStrategy, Inc.

Sine

227

Mathematical Functions

MicroStrategy Analytical Functions Reference

Usage
The value of the hyperbolic sine is used to approximate a
cumulative probability distribution.

Syntax
SINH < > (Number), where Number is the value, in radians,
whose hyperbolic sine is sought1.
1

Multiplying the argument by p/180 converts an angle from degrees to radians.

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Square root
Name
SQRT

Information returned
The square root of a given positive numerical expression.

228 Square root

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Syntax
SQRT < > (Number), where Number is the number for which
the square root is sought.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Notes

In environments listed, the database returns an error


message if Number < 0.

In environments not listed, the engine returns an empty


cell if Number < 0.

Tangent
Name
TAN

Information returned
The value of the tangent of a given angle.

Syntax
TAN < > (Number), where Number is any real number.1
1

This is the angle, in radians, for which the value of the tangent is sought. If the
argument is in degrees, it should be multiplied by p/180 for conversion to radians.

2003 MicroStrategy, Inc.

Tangent

229

Mathematical Functions

MicroStrategy Analytical Functions Reference

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Tangent, hyperbolic
Name
TANH

Information returned
The value of the hyperbolic tangent of a given number.

Syntax
TANH < > (Number), where Number can be any real number.

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

230 Tangent, hyperbolic

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Mathematical Functions

Truncate
Name
TRUNC

Information returned
The integral component of a given number.1
1 See Integer.

Syntax
TRUNC < > (Number), where Number is the number to be
truncated

Note
Results from Truncate and Integer differ only when Number
< 0.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Truncate

231

Mathematical Functions

232 Truncate

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

8
NULL AND ZERO FUNCTIONS

Introduction
The functions described in this section are used to determine
how nulls and zeros are to be displayed on a report.

2003 MicroStrategy, Inc.

233

Null and Zero Functions

MicroStrategy Analytical Functions Reference

Is Not Null
Name
ISNOTNULL

Information returned
A true or false depending on whether the argument is not
null. If a value is not null, convert it to 1, otherwise keep the
value.

Syntax
ISNOTNULL(Argument)

Note
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 also see null data when you manipulate a
report after its original generation and that process does not
regenerate the data from the database. This can happen when
you page by, for example, and the result includes a null.
ISNULL and ISNOTNULL do not apply to the data that is not
returned directly from the database.

234 Is Not Null

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Null and Zero Functions

Is Null
Name
ISNULL

Information returned
A true or false depending on whether the argument is null. If
a value is null, convert it to 0, otherwise keep the value.

Syntax
ISNULL(Argument)

Note
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 also see null data when you manipulate a
report after its original generation and that process does not
regenerate the data from the database. This can happen when
you page by, for example, and the result includes a null.
ISNULL and ISNOTNULL do not apply to the data that is not
returned directly from the database.

2003 MicroStrategy, Inc.

Is Null

235

Null and Zero Functions

MicroStrategy Analytical Functions Reference

Null to Zero
Name
NULLTOZERO

Information returned
If a value is null, convert it to zero (0), otherwise keep the
value.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Zero to Null
Name
ZEROTONULL

Information returned
If a value is zero (0), convert it to null, otherwise keep the
value.

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

236 Null to Zero

2003 MicroStrategy, Inc.

9
OLAP FUNCTIONS

Introduction

<Sortby> is applied before the engine performs the


calculation of an OLAP function.

In OLAP functions, the <Sortby> parameter can be either


a metric or an attribute.

The way in which the system flags invalid entries for a


given function depends on the database being used. Error
conditions are indicated as described below.
If the database supports the calculation being
performed, the error condition is reflected as a GUI
message.
If the calculation is performed by the MicroStrategy 7i
engine, the error condition causes an empty cell to be
returned.

2003 MicroStrategy, Inc.

237

OLAP Functions

MicroStrategy Analytical Functions Reference

Exponential weight moving average


Name
ExpWghMovingAvg

Information returned
Exponential weighted moving average

Syntax
ExpWghMovingAvg <Breakby> <Sortby> (ValueList,
WindowSize, Rate)

Expression

Exponential weight running average


Name
ExpWghRunningAvg

Information returned
Exponential weighted running average

238 Exponential weight moving average

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Syntax
ExpWghRunningAvg <Breakby> <Sortby> (ValueList,
Rate)

Expression

First value in range


Name
FirstInRange

Information returned
First value in a range of values

Syntax
FirstInRange <Breakby> <Sortby> (ValueList)

Expression

Where
2003 MicroStrategy, Inc.

First value in range

239

OLAP Functions

MicroStrategy Analytical Functions Reference

k = row number

y1 = first value of the metric after applying parameters

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Last value in range


Name
LastInRange

Information returned
Last value in a range of values

Syntax
LastInRange <Breakby> <Sortby> (ValueList)

Expression

Where

240 Last value in range

k = row number

yk = last value of the metric after applying parameters

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

Moving average
Name
MovingAvg

Information returned
The cumulative, group, or moving average of a value
expression. Return content is a function of how AVG data is
aggregated.

Syntax
MovingAvg <Breakby> <Sortby> (ValueList, WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Moving average

241

OLAP Functions

MicroStrategy Analytical Functions Reference

Moving count
Name
MovingCount

Information returned
The cumulative, group, or moving count of a value
expression. Return content is a function of how COUNT data
is aggregated.

Syntax
MovingCount <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

242 Moving count

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Moving difference
Name
MovingDifference

Information returned
The moving difference between current-row and
preceding-row column values.

Syntax
MovingDifference <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Moving difference

243

OLAP Functions

MicroStrategy Analytical Functions Reference

Moving maximum
Name
MovingMax

Information returned
The cumulative, group, or moving maximum of a value
expression. Return content is a function of how MAX data is
aggregated.

Syntax
MovingMax <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

244 Moving maximum

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Moving minimum
Name
MovingMin

Information returned
The cumulative, group, or moving minimum of a value
expression. Return content is a function of how MIN data is
aggregated.

Syntax
MovingMin <Breakby> <Sortby> (ValueList, WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Moving minimum

245

OLAP Functions

MicroStrategy Analytical Functions Reference

Moving standard deviation (of a population)


Name
MovingStDevp

Information returned
The cumulative, group, or moving standard deviation of a
population for a value expression. Return content is a
function of how STDEVP data is aggregated.

Syntax
MovingStDevp <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

246 Moving standard deviation (of a population)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Moving standard deviation (of a sample)


Name
MovingStdev

Information returned
The cumulative, group, or moving standard deviation of a
sample for a value expression. Return content is a function of
how STDEV data is aggregated.

Syntax
MovingStdev <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Moving standard deviation (of a sample)

247

OLAP Functions

MicroStrategy Analytical Functions Reference

Moving sum
Name
MovingSum

Information returned
The cumulative, group, or moving sum of a value expression.
Return content is a function of how SUM data is aggregated.

Syntax
MovingSum <Breakby> <Sortby> (ValueList,
WindowSize)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

248 Moving sum

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Running average
Name
RunningAvg

Information returned
The cumulative, group, or moving average of a value
expression. Return content is a function of how AVG data is
aggregated.

Syntax
RunningAvg <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Running average

249

OLAP Functions

MicroStrategy Analytical Functions Reference

Running count
Name
RunningCount

Information returned
The cumulative, group, or moving count of a value
expression. Return content is a function of how COUNT data
is aggregated.

Syntax
RunningCount <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

250 Running count

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Running maximum
Name
RunningMax

Information returned
The cumulative, group, or moving maximum of a value
expression. Return content is a function of how MAX data is
aggregated.

Syntax
RunningMax <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Running maximum

251

OLAP Functions

MicroStrategy Analytical Functions Reference

Running minimum
Name
RunningMin

Information returned
The cumulative, group, or moving minimum of a value
expression. Return content is a function of how MIN data is
aggregated.

Syntax
RunningMin <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

252 Running minimum

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Running standard deviation (of a population)


Name
RunningStDevp

Information returned
The cumulative, group, or moving standard deviation of a
population for a value expression. Return content is a
function of how STDEVP data is aggregated.

Syntax
RunningStDevp <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Running standard deviation (of a population)

253

OLAP Functions

MicroStrategy Analytical Functions Reference

Running standard deviation (of a sample)


Name
RunningStDev

Information returned
The cumulative, group, or moving standard deviation of a
sample for a value expression. Return content is a function of
how STDEV data is aggregated.

Syntax
RunningStDev <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

254 Running standard deviation (of a sample)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

OLAP Functions

Running sum
Name
RunningSum

Information returned
The cumulative, group, or moving sum of a value expression.
Return content is a function of how SUM data is aggregated.

Syntax
RunningSum <Breakby> <Sortby> (ValueList)

Expression

Function support
See Appendix A: Engine Functions: Database Support for a
list of the databases that support this function.

2003 MicroStrategy, Inc.

Running sum

255

OLAP Functions

256 Running sum

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

10
RANK AND TILE FUNCTIONS

Introduction
Rank functions are very similar to OLAP functions in
behavior; the primary difference is that in the Rank family
<Sortby> uses only metrics; attributes are not used for this
parameter.
When selecting a ranking option within the VLDB Properties
dialog, available values are as follows:

2003 MicroStrategy, Inc.

0: use ODBC ranking

1: ranking is performed by the analytical engine

2: ranking is performed in the database

257

10

Rank and Tile Functions

MicroStrategy Analytical Functions Reference

N-Tile
Name
NTILE

Information returned
Number of values in the metric, sorted in either ascending or
descending order, and distributed over N buckets.

Syntax
NTILE <Tiles = 4>

Example
Given N = 4 for a metric that contains 20 values, this function
would distribute the numbers as follows:

258 N-Tile

values 1 through 5 in bucket 1

values 6 through 10 in bucket 2

values 11 through 15 in bucket 3

values 16 through 20 in bucket 4

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Rank and Tile Functions

10

N-Tile Step Size


Name
NTILESIZE

Information returned
Number of values in the metric, sorted in either ascending or
descending order, and distributed by stepsize over N buckets.

Syntax
NTILESIZE <Ascending = TRUE> (Value, StepSize)

Example
NTILESIZE (M1,2)
This example returns only two buckets. The number of values
is found and then an equal number of values goes in each
bucket. The actual value does not matter, except for sorting.
If there are four values, the first two go in bucket 1 and the
second two go in bucket 2.

2003 MicroStrategy, Inc.

N-Tile Step Size

259

10

Rank and Tile Functions

MicroStrategy Analytical Functions Reference

N-Tile Value
Name
NTILEVALUE

Information returned
Number of values in the metric, sorted in either ascending or
descending order, and distributed by range over N buckets.

Syntax
NTILEVALUE <Segments = N, Ascending = TRUE>
(Value)

Example
Given x as a value in a metric with N = 4, if the minimum
value of x is 5 and the maximum 105, the bucket distribution
is as follows:

260 N-Tile Value

5 x < 30 in bucket 1

30 x < 55 in bucket 2

55 x < 80 in bucket 3

80 x < 105 in bucket 4

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

10

Rank and Tile Functions

N-Tile Value Step Size


Name
NTILEVALUESIZE

Information returned
Number of values in the metric, sorted in either ascending or
descending order, and distributed by range over N buckets,
and by stepsize over N buckets.

Syntax
NTILEVALUESIZE <Ascending/Decending> <Breakby>
([V], StepSize)

Example
NTILEVALUESIZE (M1, 1000)
This starts with the minimum value of M1, for example, 1200,
and puts it in bucket 1. Bucket 2 would be 2200-3200, and
any values in that range would be in bucket 2 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.

Percentile
Name
PERCENTILE

2003 MicroStrategy, Inc.

N-Tile Value Step Size

261

10

Rank and Tile Functions

MicroStrategy Analytical Functions Reference

Information returned
The percent-th percentile of values in a given range.

Syntax
PERCENTILE <Ascending = TRUE> (Value, Percent)

Example
Given a fact column containing the values 1, 2, 3, and 4:
PERCENTILE ({1, 2, 3, 4}, 0.3) = 1.9

Rank by Value
Name
RANK

Information returned
The order ranking of rows for the expression as specified in
the Order By clause of the SQL statement. .

Syntax
RANK <Asc = TRUE, ByValue= TRUE> (Value)

262 Rank by Value

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Rank and Tile Functions

10

Rank by Percent
Name
RANK

Information returned
The order ranking of percent values for the expression as
specified in the Order By clause of the SQL statement.

Syntax
RANK <Asc = TRUE, ByPercent= TRUE> (Percent)

2003 MicroStrategy, Inc.

Rank by Percent

263

10

Rank and Tile Functions

264 Rank by Percent

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

11
STATISTICAL FUNCTIONS

Introduction
The way in which the system flags invalid entries for a given
function depends on the database being used. Error
conditions are indicated as described below.

2003 MicroStrategy, Inc.

If the database supports the calculation being performed,


the error condition is reflected as a GUI message.

If the calculation is performed by the MicroStrategy 7i


engine, the error condition causes an empty cell to be
returned.

265

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Average deviation
Name
AVGDEV

Information returned
Average of the absolute deviations of a set of data in a fact
table.1
1 Average deviation

is the measure of the variability in a data set.

Syntax
AVGDEV < > ([Fact]) {~+} <FL>|TR|

Expression

* In this expression, x is a value in a fact table.

266 Average deviation

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Beta distribution
Name
BETADISTRIBUTION

Information returned
The cumulative beta distribution of a random variable.1
1 This function is used

to study percentage variations for an item across population


samples (for instance, how much of a day people spend watching television).

Syntax
BETADISTRIBUTION < Lower Bound = 0, Upper Bound =
1 > (x, alpha, beta), where

x is the value between Lower Bound and Upper Bound


at which the function is evaluated

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

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

x, alpha, or beta is nonnumeric.

alpha 0 or beta 0

x < Lower Bound or x > Upper Bound

Lower Bound = Upper Bound

Beta distribution

267

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Beta distribution, inverse of


Name
INVERSEBETADISTRIBUTION

Information returned
Inverse of the Beta distribution.

Syntax
INVERSEBETADISTRIBUTION < Lower Bound = 0, Upper
Bound = 1 > (probability, x, alpha, beta), where

probability is a probability associated with the beta


distribution

x is the value between Lower Bound and Upper Bound


at which the function is evaluated

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

Note
The following are invalid conditions:

268 Beta distribution, inverse of

x, alpha, or beta is nonnumeric.

alpha 0 or beta 0

probability 0 or probability > 1

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

x < Lower Bound or x > Upper Bound

Lower Bound = Upper Bound

11

Binomial distribution
Name
BINOMIALDISTRIBUTION

Information returned
Either the binomial probability or the cumulative binomial
probability of a random variable.1
1

This function is used in cases in which:


there is a fixed number of tests
test outcome is binary, that is, each test can only result in either success or failure
tests are independent of all other tests
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 = 0> (x, n, p),
where

2003 MicroStrategy, Inc.

x is the number of successes

n is the number of tests

p is the probability of a success in each trial

Cumulative is a logical value that determines the form of


the function

Binomial distribution

269

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Expression
For the binomial probability:

Where

For the cumulative binomial distribution:

Notes

If x or n is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


one of the arguments is nonnumeric
p < 0 or p > 1

Chi-square distribution
Name
CHISQUAREDISTRIBUTION

270 Chi-square distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Information returned
The one-tailed probability of the chi-squared distribution.1
1

The chi-squared ( 2) distribution is associated with an 2 test. An 2 test is used to


compare observed values against expected ones to determine the validity of a hypothesis (for example, 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 the value at which the distribution is evaluated

df is the number of degrees of freedom for the distribution

Notes

If df is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


either argument is nonnumeric
x<0
df < 1
df > 1010

Chi-squared distribution, inverse of


Name
INVERSECHIDISTRIBUTION

2003 MicroStrategy, Inc.

Chi-squared distribution, inverse of

271

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Information returned
The inverse, or critical value, of a given chi-squared
distribution greater than or equal to a pre-specified value [if
probability = ChiDistribution (x...), then
InverseChiDistribution (probability...) = x.]

Usage
This function is used to compare observed results against
expected ones to assess the validity of a hypothesis.

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.

Notes

If df is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


either argument is nonnumeric
x < 0 or x >1
df< 1
df > 1010

272 Chi-squared distribution, inverse of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

11

Statistical Functions

Chi-square test for independence


Name
CHISQUARETEST

Information returned
The result of a test for independence.1
1 This function returns the chi-squared ( 2) distribution for a statistic value and

its
associated degrees of freedom (to determine, for example, to what extent an experiment verifies hypothesized results).

Syntax
CHISQUARETEST < > (Fact1, Fact2) {~+} <FL>|TR|, where

Fact1 is a data array that contains observations to be


tested against expected values

Fact2 is a data array that contains the ratio of the product


of row totals and column totals to the grand total

Notes

2003 MicroStrategy, Inc.

This function returns the probability for an 2 statistic and


its associated degrees of freedom (df), where df =
(r-1)(c-1).

Chi-squared calculates a statistic value and then adds the


differences between actual values and expected ones (see
Chi-squared distribution).

This function results in an invalid value if Fact1 and


Fact2 differ in the number of data points they contain.

Chi-square test for independence

273

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Confidence interval
Name
CONFIDENCE

Information returned
Confidence interval for a population mean.1
1 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.2

stdev is the standard deviation of the population for the


given data range (assumed to be know; see Standard
deviation of a population).

size is the size of the sample.

The confidence level is expressed as [100(1-alpha)%].

Expression
If alpha = 0.05, then:

274 Confidence interval

CONFIDENCE = 95%

the area equivalent to 95% of the population = 1.96

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

the confidence interval is

Notes

If size is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


one of the arguments is nonnumeric
alpha < 0 or alpha >1
stdev < 0
size < 1

2003 MicroStrategy, Inc.

Confidence interval

275

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Correlation
Name
CORRELATION

Information returned
The correlation coefficient between two data sets. Correlation
denotes association between two quantitative variables, and
how related or associated these values are.

Syntax
CORRELATION < > (Fact1, Fact2) {~+} where

Fact1 is a cell range of values.

Fact2 is a second cell range of values

Notes

276 Correlation

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.

The arguments must be numbers or names, arrays, or


references that contain numbers.

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.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

2003 MicroStrategy, Inc.

Statistical Functions

11

If Fact1 and Fact2 have a different number of data points,


CORRELATION returns an error.

If either Fact1 or Fact2 is empty, or if the standard


deviation of their values equals zero, CORRELATION
returns an error.

Correlation

277

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Covariance
Name
COVARIANCE

Information returned
Product average of the deviations for each data point pair in
two given sets of values.1
1

Covariance determines the relationship between data points in two data arrays
(for example, how -- or if -- greater income is related to higher education levels).

Syntax
COVARIANCE < > (Fact1, Fact2) {~+} <FL>|TR|, where
Fact1 and Fact2 are data sets whose covariance is sought.

Expression

* In the expression that follows, Fact = X, Fact = Y.


1

Note
The following are invalid conditions:

278 Covariance

Fact1 and Fact2 do not contain the same number of data


points

either value set is empty

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Criterion binomial
Name
CRITBINOMIAL

Information returned
The smallest value for which the cumulative binomial
distribution is less than or equal to a criterion value.

Syntax
CRITBINOMIAL(trials, probability_s, apha), where

trials is the number of Bernoulli trials.

probability_s is the probability of a success on each trial.

alpha is the criterion value.

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

any argument is nonnumeric

trials is not an integer

trials < 0

probability_s is < 0 or probability_s > 1

alpha < 0 or alpha > 1

Criterion binomial

279

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Exponential distribution
Name
EXPONENTIALDISTRIBUTION

Information returned
Either the probability density or the cumulative distribution
of a random variable.1
1

This function is used to model the time elapsed between events (for example, to
estimate the probability that an automatic-teller machine will take no more than
one minute to deliver requested cash).

Syntax
EXPONENTIALDISTRIBUTION <Cumulative = 0> (x,
lambda), where

x is the value of the function

lambda is the value of the parameter

Cumulative is a logical value that determines the form of


the function

Expression

280 Exponential distribution

For probability density:

For cumulative distribution:

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Note
The following are invalid conditions:

either x or lambda is nonnumeric

x<0

lambda 0

Fisher transformation
Name
FISHER

Information returned
The Fisher transformation at x.1
1

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), where x is the numeric value for which the
transformation is sought.

Expression

2003 MicroStrategy, Inc.

Fisher transformation

281

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Note
The following are invalid conditions:

x is nonnumeric

x -1 or x 1

Fisher transformation, inverse of


Name
INVERSEFISHER

Information returned
Inverse of the Fisher transformation.1
1 This function is used to analyze correlations between data arrays (see also Fisher

transformation).

Syntax
INVERSEFISHER(x), where x is the value for which the
inverse of the Fisher transformation is performed.

Expression

Note
This function results in an invalid value if x is nonnumeric.

282 Fisher transformation, inverse of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

F-probability distribution
Name
FDISTRIBUTION

Information returned
The cumulative distribution (F-probability) of a random
variable.1
1 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

df1 represents the degrees of freedom of numerator values

df2 represents the degrees of freedom of denominator


values

Expression
P = (F<X),
Where F is a random variable that has an F distribution.

Notes

2003 MicroStrategy, Inc.

If df1 or df2 is not an integer, it is truncated to its integral


component.

F-probability distribution

283

11

Statistical Functions

MicroStrategy Analytical Functions Reference

The following are invalid conditions:


an argument is non-numeric
x<0
df1 < 1 or df1 1010
df2 < 1 or df2 1010

F-probability distribution, inverse of


Name
INVERSEFDISTRIBUTION

Information returned
Inverse of the F probability distribution.1
1 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).
See also F-probability distribution.

Syntax
INVERSEFDISTRIBUTION < > (x, df1, df2) where

x is the probability associated with the F cumulative


distribution

df1 represents the degrees of freedom of numerator values

df2 represents the degrees of freedom of denominator


values

284 F-probability distribution, inverse of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

11

Statistical Functions

Notes

If df1 or df2 is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


an argument is nonnumeric
x< 0 or x > 1
df1 < 1 or df1 1010
df2 < 1 or df2 1010

F-test
Name
FTEST

Information returned
The one-tailed probability that variances in two vectors or
value arrays Fact1 and Fact2 are not significantly different
(for example, given the test scores from public and private
schools, this functions allows you to determine whether
diversity levels between the two school types are significantly
different).

Syntax
FTEST <Hypothesis type = 0, Ratio = 1> (Fact1, Fact2),
where

2003 MicroStrategy, Inc.

Fact1 is a vector or array of values

Fact2 is a vector or array of values

F-test

285

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Hypothesis type is a logical value that determines the


form of the function

Note
The following are invalid conditions:

the number of data points in Fact1 is different from that


in Fact2

the variance of either data set is zero

Gamma distribution
Name
GAMMADISTRIBUTION

Information returned
Either the cumulative distribution or the probability density
of a random variable.1
1

This function is used in queueing analysis to study variables that may have a
skewed distribution.

Syntax
GAMMADISTRIBUTION <Cumulative = 0> (x, alpha, beta),
where

286 Gamma distribution

x is the value at which you want to evaluate the


distribution

alpha is a distribution parameter

beta is a distribution parameter

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Cumulative is a logical value that determines the form of


the function

Expression

The expression for the standard gamma distribution is:

If alpha = 1, this function returns the exponential


distribution as:

Notes

When alpha > 0, this function is also known as the Erlang


distribution.

The following are invalid conditions:


either alpha or beta is nonnumeric
either alpha 0 or beta 0
x<0

2003 MicroStrategy, Inc.

Gamma distribution

287

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Gamma distribution, inverse of


Name
INVERSEGAMMADISTRIBUTION

Information returned
Inverse of the Gamma distribution.

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

Note
The following are invalid conditions:

either alpha or beta is nonnumeric

either alpha 0 or beta 0

x < 0 or x > 1

288 Gamma distribution, inverse of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Gamma distribution, logarithm of


Name
GAMMADISTRIBUTIONLN

Information returned
The natural logarithm of the gamma distribution.

Syntax
GAMMADISTRIBUTIONLN (x), where x is the value whose
logarithm is to be calculated.

Expression

Where

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

x is nonnumeric

x0

eGammaDistributionLn(i) (where i is an integer) returns the


same value as Interception (point)

Gamma distribution, logarithm of

289

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Hypergeometric distribution
Name
HYPERGEOMETRICDISTRIBUTION

Information returned
For the hypergeometric distribution, the probability of a
given number of sample successes, given the sample size,
population successes, and population size. Use
HYPERGEOMETRICDISTRIBUTION 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), 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

290 Hypergeometric distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Notes

All arguments are truncated to integers.

The following are invalid conditions:


Any argument is nonnumeric
x < 0 or x is greater than the lesser of n or M
x is less than the larger of 0 or (n - N + M)
n < 0 or n > N
M < 0 or M > N
N<0

Intercept
Name
INTERCEPT

Information returned
Point at which a line intersects the y-axis in a graph.1
1 This function is used

to determine the value of a dependent variable (y) when the


value of its associated independent variable (x) is 0 (zero). The point of intersection
is based on a best-fit regression line plotted through available values (x) for Fact1
(the independent-variable range) and values (y) for Fact2 (the dependent-variable
range).

Syntax
INTERCEPT < > (Fact1, Fact2) {~+} <FL>|TR| where

2003 MicroStrategy, Inc.

Fact1 is the dependent set of observation data

Fact2 is the independent set of observation data

Intercept

291

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Expression

* In the expressions that follow, Fact = Y, Fact = X.


1

The equation for the intercept of the regression line is

The slope of the regression line is calculated as:

Note
This function results in an invalid value if the number of data
points (y) in Fact2 is different from the number of data
points (x) in Fact1.

Kurtosis
Name
KURTOSIS

Information returned
Kurtosis (relative flatness) of the values in a given set of fact
table.1
1

Kurtosis characterizes the relative peakedness or flatness of a distribution


when compared to a normal distribution: a positive kurtosis indicates a relatively
peaked distribution; a negative one signifies a relative flat distribution.

292 Kurtosis

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Syntax
KURTOSIS < > (Fact) {~+} <FL>|TR|, where Fact is a set of
values (x) whose relative flatness is sought.

Expression
the expression that follows, s is the sample
* Instandard
deviation.

Lognormal distribution
Name
LOGNORMALDISTRIBUTION

Information returned
Lognormal cumulative distribution of a random variable x
[ln(x) that is normally distributed, with mean and standard
deviation as parameters].1
1 This function is used

to analyze data that has been logarithmically transformed.

Syntax
LOGNORMALDISTRIBUTION < > (x, mean, stdev), where

2003 MicroStrategy, Inc.

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)

Lognormal distribution

293

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Expression

* In the expression that follows, mean = m, stdev = s.


Note
The following are invalid conditions:

one of the arguments is nonnumeric

x0

stdev 0

Lognormal distribution, inverse of


Name
INVERSELOGNORMALDISTRIBUTION

Information returned
Inverse of the lognormal cumulative distribution function.1
1 ln(x)

294 Lognormal distribution, inverse of

is normally distributed using mean and standard deviation as parameters.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

11

Statistical Functions

Syntax
INVERSELOGNORMALDISTRIBUTION < > (x, mean,
stdev) 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.


Note
The following are invalid conditions:

one of the arguments is nonnumeric

x<0

x>1

stdev < 0

Negative binomial distribution


Name
NEGATIVEBINOMIALDISTRIBUTION

2003 MicroStrategy, Inc.

Negative binomial distribution

295

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Information returned
Negative binomial distribution (the probability that there will
be n failures before the nth success when the constant
probability of a success is p).1
1 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

Expression

* In the expression that follows, f = x, s = r.


Notes

If either f or s is not an integer, it is truncated to its


integral component.

The following are invalid conditions:


one of the arguments is nonnumeric
p < 0 or p > 1
f + (s - 1) 0

296 Negative binomial distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Normal cumulative distribution


Name
NORMALDISTRIBUTION

Information returned
Either the cumulative distribution or the probability density
of a random variable.1
1

This function has wide application in statistics, including the area of hypothesis
testing.

Syntax
NORMALDISTRIBUTION <Cumulative = 0> (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:

Expression

* Ins. the expression that follows, z = x, mean = m, stdev =

2003 MicroStrategy, Inc.

Normal cumulative distribution

297

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Note
The following are invalid conditions:

either mean or stdev is nonnumeric

stdev 0

If mean = 0 and stdev = 1, this function returns the


standard normal distribution.

Normal cumulative distribution, inverse of


Name
INVERSENORMDISTRIBUTION

Information returned
Inverse, or critical value, of the normal cumulative
distribution for a given mean and standard deviation (see
Normal cumulative distribution).

Syntax
INVERSENORMDISTRIBUTION < > (x, mean, stdev),
where

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

298 Normal cumulative distribution, inverse of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Notes

If mean = 0 and stdev = 1, this function returns the


standard normal distribution.

The following are invalid conditions:


one of the arguments is nonnumeric.
stdev 0

Pearson product moment correlation


coefficient
Name
PEARSON

Information returned
The Pearson product moment correlation coefficient of a set
of values.1
1

This coefficient (r), is a dimensionless index that ranges from -1.0 to 1.0 (inclusive).

Usage
The Pearson product moment correlation coefficient is used
to determine the extent of a relationship between two data
sets.

Syntax
PEARSON < > (Fact1, Fact2), where

2003 MicroStrategy, Inc.

Pearson product moment correlation coefficient

299

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Fact1 is a vector or data array containing independent


values

Fact2 is a vector or data array containing dependent


values

Expression

* In the expression that follows, Fact = X, Fact = Y.


1

Note
The following are invalid conditions:

either Fact1 or Fact2 contains one or more null values

Fact1 and Fact2 do not contain the same number of data


points

Pearson product moment correlation


coefficient, square of
Name
RSQUARE

Information returned
Square of the Pearson product moment correlation
coefficient for a set of values.1
1 The value of the square of

r is the proportion of the variance in y that is attributable to the variance in x (see Pearson product moment correlation coefficient).

300 Pearson product moment correlation coefficient, square of

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Syntax
RSQUARE < > (Fact1, Fact2) {~+} <FL> |TR|, where

Fact1 is a vector or array of data-point coordinates

Fact2 is a vector or array of data point coordinates

Note
The following are invalid conditions:

Fact1 and Fact2 do not have the same number of values

either Fact1 or Fact2 contains one or more null values

Permutation
Name
PERMUT

Information returned
The number of possible permutations for a given number of
items selected as a group from a set.1
1 In permutation calculations, the internal order of the items selected affects the re-

turn (as opposed to the case of a combination, in which the order of the items selected does not affect the return; see also Combination).

Syntax
PERMUT < > (Number, Number_Chosen), where

2003 MicroStrategy, Inc.

Number is the number of items in a set

Number_Chosen is the number of items selected for


permutation
Permutation

301

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Expression
the expression that follows, Number = n;
* InNumber_Chosen
= k.

Notes

If an argument is not an integer it is truncated to its


integral component.

This function returns an error value if


either argument is nonnumeric
n< 0
k<0
nk

Poisson distribution
Name
POISSONDISTRIBUTION

Information returned
The Poisson distribution of a random variable.

Usage
Predicting the number of identified events to take place over
a specified period (for example, the number of cars to arrive
at a toll plaza in a one-minute interval).

302 Poisson distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

11

Statistical Functions

Syntax
POISSONDISTRIBUTION <Type> (x, mean), where

x is the number of events in the prediction

mean is the expected numeric value of the expression

Type is a logical value that determines the form of the


probability distribution:
if Type = 0, the function returns the probability that
the number of random events will be between 0 and x
if Type = 1, the function returns the probability that
the number of random events will be exactly x

Expression

For type = 1:

For type = 0:

Notes

If x is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


x or mean is nonnumeric
x0
mean 0

2003 MicroStrategy, Inc.

Poisson distribution

303

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Skew
Name
SKEW

Information returned
Skewness of a data set in a given vector or data array.1
1

Skewness is the degree of asymmetry of a distribution in relation to its mean. A


positive skewness indicates asymmetry biased towards positive values; a negative
skewness, the opposite.

Syntax
SKEW < > (Fact) {~+} <FL>|TR|, where Fact is a set of
values (x) whose skewness is sought.

Expression

Note
Teradata V2R4 supports calculation of this function; in all
other environments, the MicroStrategy 7i engine handles the
calculation.

304 Skew

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Slope (of a linear regression)


Name
SLOPE

Information returned
The slope of a linear regression line.1
1

In a regression line passing through a set of data points in data sets Fact1 and
Fact2, the slope is the vertical distance divided by the horizontal distanced between
any two points on the line. This ratio is also known as the rate of change along the
line.

Syntax
SLOPE < > (Fact1, Fact2), where

Fact1 is a vector or array containing numerically


dependent (y) data points

Fact2 is a vector or array containing numerically


independent (x) data points

Expression

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

either Fact1 or Fact2 contains null values

Fact1 and Fact2 do not have the same number of values

Slope (of a linear regression)

305

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Standard error of estimates


Name
STEYX

Information returned
The standard error of estimates in linear regression with two
variables, for example, X = Slope + Intercept * Y

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

Notes

306 Standard error of estimates

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.

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

The following are invalid conditions:


Arguments are not numbers or names, arrays, or
references that contain numbers
Y and X are empty or have a different number of data
points

Standardize
Name
STANDARDIZE

Information returned
A normalized value from a distribution characterized by
mean and standard_dev.

Syntax
STANDARDIZE(x,mean,standard_dev), where

X is the value you want to normalize

mean is the arithmetic mean of the distribution

standard_dev is the standard deviation of the


distribution

Expression

2003 MicroStrategy, Inc.

Standardize

307

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Note
The following is an invalid condition:

standard_dev 0

Standard normal cumulative distribution


Name
STANDARDNORMALDISTRIBUTION

Information returned
Standard normal cumulative distribution of a random
number (the mean is 0; the standard deviation is 1).

Usage
This function can be used in lieu of a table of standard normal
curve areas.

Syntax
STANDARDNORMALDISTRIBUTION < > (x), where x is a
value for which the distribution is sought.

Expression

308 Standard normal cumulative distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Note
This function results in an invalid value if x is nonnumeric.

Standard normal cumulative distribution,


inverse of
Name
INVERSENORMSDISTRIBUTION

Information returned
Inverse, or critical value, of the standard normal cumulative
distribution.1
1

This function computes the critical value so that the cumulative distribution is
greater than or equal to a pre-specified value.

Syntax
INVERSENORMSDISTRIBUTION < > (x), where x is the
probability corresponding to the normal distribution.

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

x is nonnumeric

x < 0 or x > 1

Standard normal cumulative distribution, inverse of

309

11

Statistical Functions

MicroStrategy Analytical Functions Reference

T-distribution
Name
TDISTRIBUTION

Information returned
The cumulative distribution of a random variable.1
1 This function can be used

in lieu of a table of critical values to test hypotheses on

small sample sets.

Hypothesis functions
For both variance types, hypothesis functions are as follows:
Decision

Logic Status
HO correct

H1 correct

Accept HO

Yes

Type 1 error

Reject HO

Type 2 error

Yes

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
p ( x < X ), where X is a random value that follows the
t-distribution.
310 T-distribution

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Notes

If df is not an integer, it is truncated to its integral


component.

The following are invalid conditions:

either x or df is nonnumeric

df < 1

T-distribution, inverse of
Name
INVERSETDISTRIBUTION

Information returned
Inverse of T-distribution.

Hypothesis functions
For both variance types, hypothesis functions are as follows:
Decision

2003 MicroStrategy, Inc.

Logic Status
HO correct

H1 correct

Accept HO

Yes

Type 1 error

Reject HO

Type 2 error

Yes

T-distribution, inverse of

311

11

Statistical Functions

MicroStrategy Analytical Functions Reference

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
p ( t < X ), where X is a random value that follows the
t-distribution.

Notes

If df is not an integer, it is truncated to its integral


component.

The following are invalid conditions:


either probability or df is nonnumeric
probability < 0 or probability > 1
df < 1

T-test, mean
Name
MEANTTEST

312 T-test, mean

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

11

Statistical Functions

Information returned
Probability values for a t-test.1
1

This function is used to determine the closeness in the value of the means of two
samples coming from the same population V.

Hypothesis functions
For both variance types, hypothesis functions are as follows:
Decision

Logic Status
HO correct

H1 correct

Accept HO

Yes

Type 1 error

Reject HO

Type 2 error

Yes

Syntax
MEANTTEST <Hypothesis type = 0> (Fact, Hypothesis
mean) {~+} <FL> |TR|, where

Fact is the vector or value array that contains sample data

Hypothesis mean specifies the number of distribution


tails (1 denotes a one-tailed distribution; 2 denotes a
two-tailed distribution)

Hypothesis type denotes the type of t-test to be


performed

Notes

2003 MicroStrategy, Inc.

If Hypothesis mean or Hypothesis type is not an


integer, it truncated to its integral component.

T-test, mean

313

11

Statistical Functions

MicroStrategy Analytical Functions Reference

The following are invalid conditions:


either Hypothesis mean or Hypothesis type is
nonnumeric
Hypothesis mean is a value other than 1 or 2
Hypothesis type 0

T-test, paired two-sample (for means)


Test name
PAIREDTTEST

Information Returned
The P value for a hypothesis test.1
1 Possible Mean/Offset/Type

relationships for the return are as follows:


H0: Mean([Fact1 Fact2]) = Offset
H1: Mean([Fact1 Fact2]) < Offset [Type = 1]
H1: Mean([Fact1 Fact2]) Offset [Type = 0: Two-sided test]
H1: Mean([Fact1 Fact2]) > Offset [Type = 1]
H1: Mean([Fact1 Fact2]) Offset [Type = 2: One-sided test]

Usage
Two-sample analyses are used to determine the level of
variance between the means of paired samples.
See also T-test.

Syntax
PAIREDTTEST <Type, Offset> (Fact1, Fact2) {~+}
<FL>|TR|, where

Fact1 is a set of sample values

314 T-test, paired two-sample (for means)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

Fact2 is a set of sample values

Type is a logical value that determines the form of the


function

11

Note
One of the results of this sample is pooled variance, an
accumulated measure of spread data about the mean. Pooled
variance is calculated as:

2003 MicroStrategy, Inc.

T-test, paired two-sample (for means)

315

11

Statistical Functions

MicroStrategy Analytical Functions Reference

T-test, two-sample
Test names

Heteroscedastic t-test

Homoscedastic t-test

Usage
To determine the level of variance between the means of
paired samples (for example, when a given group is to be
tested before and after an experiment).

Test assumptions
Heteroscedastic t-tests are based on the assumption that
variances between two sample data ranges are unequal
[var(Fact1) var(Fact2)].
Homoscedastic t-tests are based on the assumption that
variances between two sample data ranges are equal
[var(Fact1) = var(Fact2)].
See also MeanT-test.

Hypothesis functions
For both variance types, hypothesis functions are as follows:
Decision

316 T-test, two-sample

Logic Status
HO correct

H1 correct

Accept HO

Yes

Type 1 error

Reject HO

Type 2 error

Yes

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Syntax
HETEROSCEDASTICTTEST or HOMOSCEDASTICTTEST
HETEROSCEDASTICTTEST or HOMOSCEDASTICTTEST
<Hypothesis type, offset> (Fact1, Fact2) {~+} <FL>|TR|,
with the following conditions:

For H0:
Mu(Fact1) - Mu(Fact2) = offset

For H1:
Mu(Fact1) - Mu(Fact2) < offset (type = -1)
Mu(Fact1) - Mu(Fact2) offset (type = 0: two-sided
test)
Mu(Fact1) - Mu(Fact2) > offset (type = 1)
Mu(Fact1) - Mu(Fact2) offset (type = 2: one-sided
test)

Note
The following are invalid conditions:

2003 MicroStrategy, Inc.

Fact1 and Fact2 have a different number of data points,


and Hypothesis type = 1 (paired)

offset or Hypothesis type is nonnumeric

offset is any value other than 1 or 2

T-test, two-sample

317

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Variance test
Name
VARTEST

Information returned
Returns the P-value for the hypothesis test in the following
form:
H0: Var(V) = Sigma_0
vs.
H1: Var(V) < Sigma_0 [Type = -1]
H1: Var(V) Sigma_0 [Type = 0: Two-sided test]
H1: Var(V) >Sigma_0 [Type = 1]
H1: Var(V) Sigma_0 [Type = 2: One-sided test]

Syntax
VARTEST <Type> ([V], Sigma_0) {~+} where TBD

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

V is the value you are testing

Sigma_0 is the variance you are testing

Example
VarTest(M1, 1000) Sigma_O = 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.

318 Variance test

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Statistical Functions

11

Note
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.

Weibull distribution
Name
WEIBULLDISTRIBUTION

Information returned
Either the cumulative distribution or the probability density
of a random variable.

Usage
In reliability analysis (for example, the calculation of the
mean time to failure for a given device).

Syntax
WEIBULLDISTRIBUTION <Cumulative = 0> (x, alpha,
beta), where

2003 MicroStrategy, Inc.

x is the numeric value at which the distribution is


evaluated

alpha is a distribution parameter

beta is a distribution parameter

Weibull distribution

319

11

Statistical Functions

MicroStrategy Analytical Functions Reference

Cumulative is a logical value that determines the form of


the function.

Expression

For the Weibull cumulative distribution:

For the Weibull probability density:

When alpha = 1, the Weibull exponential return is

Note
The following are invalid conditions:

320 Weibull distribution

alpha or beta is nonnumeric

x<0

alpha < 0

beta < 0

2003 MicroStrategy, Inc.

12
STRING FUNCTIONS

Introduction
The MicroStrategy 7i Analytical Engine does not calculate
string functions. String functions for which your database
does not include SQL syntax support cannot be
calculated in your environment.

2003 MicroStrategy, Inc.

321

12

String Functions

MicroStrategy Analytical Functions Reference

Concatenate
Name
Concat

Information returned
A string resulting from the concatenation of two input
strings.

Syntax
Concat (S1, S2), where

S1 is the left-string portion of the result

S2 is the right-string portion of the result

The table shows the format for Concatenate in each


certified database.

322 Concatenate

Database

Format

DB2 UDB

CONCAT(S1, S2)

DataJoiner

CONCAT(S1, S2)

Informix

(S1|| S2)

Oracle

CONCAT(S1, S2)

Redbrick

CONCAT(S1, S2)

SQL Server

(S1 + S2)

Tandem

{fn CONCAT(S1, S2)}

Sybase

(S1 + S2)

Teradata

S1|| S2

Access

S1&S2

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

String Functions

12

Concatenate with a Blank


Name
ConcatBlank

Information returned
A string that is the concatenation of two input strings, with a
blank character in between.

Syntax
Concat (S1, S2), where

S1 is the left-string portion (before the blank)

S2 is the right-string portion of the result (after the blank)

The table shows the format for Concatenate with a blank in


each certified database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

CONCAT(CONCAT(S1, ), S2)

DataJoiner

CONCAT(CONCAT(S1, ), S2)

Informix

(S1|| ||S2)

Oracle

CONCAT(CONCAT(S1, ), S2)

Redbrick

CONCAT(CONCAT(S1, ), S2)

SQL Server

S1 + + S2

Tandem

{fn CONCAT ({fn CONCAT(S1, )}, S2

Sybase

S1 + + S2

Teradata

S1 + + S2

Access

S1 & & S2

Concatenate with a Blank

323

12

String Functions

MicroStrategy Analytical Functions Reference

Initial Cap
Name
InitCap

Information returned
A string in which the first letter of the input string is
capitalized; all other letters appear in lower case.

Syntax
InitCap(S)
The table shows the format for Initial cap in each certified
database.

324 Initial Cap

Database

Format

DB2 UDB

CONCAT(UCASE(SUBSTR(S, 1, 1)),
LCASE(SUBSTR(S, 2)))

Informix

INITCAP(S)

Oracle

INITCAP(S)

Redbrick

CONCAT(UPPER(SUBSTR(S, 1, 1)),
LOWER(SUBSTR(S, 2)))

SQL Server

UPPER(SUBSTRING(S 1, 1) +
LOWER(SUBSTRING(S, 2, 100)

Sybase

UPPER(SUBSTRING(S1, 1) +
LOWER(SUBSTRING(S, 2, 100)

Teradata

UPPER(SUBSTRING(S from 1for 1)||


LOWER(SUBSTRING(Sr, from 2)

Access

UCASE(MID(S, 1, 1) & LCASE(MID(S, 2))

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

String Functions

12

Length
Name
Length

Information returned
The number of characters in an input string.

Syntax
Length(S)
The table shows the format for Length in each certified
database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

LENGTH(S)

DataJoiner

LENGTH(S)

Informix

LENGTH(S)

Oracle

LENGTH(S)

Redbrick

LENGTH(S)

SQL Server

LEN(S)

Tandem

{fn LENGTH(S)}

Sybase

CHAR_LENGTH(S

Teradata

CHAR_LENGTH(S)

Access

LEN(S)

Length

325

12

String Functions

MicroStrategy Analytical Functions Reference

Lower Case
Name
Lower

Information returned
A string in which all upper-case alphabetic characters in an
input string have been converted to lower case.

Syntax
Lower(S).
The table shows the format for Lower case in each certified
database.

326 Lower Case

Database

Format

DB2 UDB

LCASE(S)

DataJoiner

LCASE(S)

Informix

LOWER(S)

Oracle

LOWER(S)

Redbrick

LOWER(S)

SQL Server

LOWER(S)

Sybase

LOWER(S)

Teradata

LOWER(S)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

String Functions

12

Position of first occurrence


Name
Position

Information returned
The starting position of the first occurrence in the input
string.

Syntax
Position (S1, S2), where

S1 is the string

S2 is the substring sought

The table shows the format for Position of first occurrence


in each certified database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

LOCATE(S1, S2)

DataJoiner

LOCATE(S1, S2)

Oracle 8i

INSTR(S1, S2)

SQL Server

CHARINDEX(S1, S2)

Sybase

CHARINDEX(S1, S2)

Teradata

INDEX(S1, S2)

Position of first occurrence

327

12

String Functions

MicroStrategy Analytical Functions Reference

String (from the inputs) Left


Name
LeftStr

Information returned
A substring having a specified number of characters from the
left of the input string.

Syntax
LeftStr (S, n), where

S is the string

n is the number of characters to be returned

The table shows the format for Right string in each certified
database.

328 String (from the inputs) Left

Database

Format

DB2 UDB

LEFT(S, n)

DataJoiner

LEFT(S, n)

Informix

SUBSTR(S, 1, n)

Oracle

SUBSTR(S, 1, n)

Redbrick

SUBSTR(S, 1, n)

SQL Server

LEFT(S, n)

Tandem

{fn SUBSTRING(S, 1, 100)}

Sybase

SUBSTRING(lS, 3, 100)

Teradata

SUBSTR(S, 1)

Access

MID(S, 1)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

12

String Functions

String (from the inputs) Right


Name
RightStr

Information returned
A substring having a specified number of characters from the
right of the input string.

Syntax
RightStr (S, n), where

S is the string

n is the number of characters to be returned

The table shows the format for Right string in each certified
database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

RIGHT(S, n)

DataJoiner

RIGHT(S, n)

Informix

SUBSTR(S, (LENGTH(S)-n+1))

Oracle

SUBSTR(S, (LENGTH(S)-n+1))

Redbrick

SUBSTR(S, (LENGTH(S)-n+1))

SQL Server

RIGHT(S, n)

Sybase

SUBSTRING(S, (CHAR_LENGTH(S)-3+1), 100)

Teradata

SUBSTR(S, (LENGTH(S)-n+1))

Access

MID(S, (LEN(S)-n+1))

String (from the inputs) Right

329

12

String Functions

MicroStrategy Analytical Functions Reference

Substring
Name
SubStr

Information returned
A substring as a sequence of characters taken from the input
string.

Syntax
SubStr(S, n1, n2), where

S is the string

n1 is the starting position inside the string

n2 is the number of characters to be returned

The table shows the format for Substring in each certified


database.

330 Substring

Database

Format

DB2 UDB

SUBSTR(S, n1, n2)

DataJoiner

SUBSTR(S, n1, n2)

Informix

SUBSTR(S, n1, n2)

Oracle

SUBSTR(S, n1, n2)

Redbrick

SUBSTR(S, n1, n2)

SQL Server

SUBSTR(S, n1, n2)

Tandem

{fn SUBSTRING(S, n1, n2)}

Sybase

SUBSTRING(S, n1, n2)

Teradata 2.4

SUBSTRING(S FROM n1 FOR n2)

Access

MID(S, n1, n2)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

String Functions

12

Trim
Name
Trim

Information returned
A string in which blanks on either side of the input string
have been removed.

Syntax
Trim(S)
The table shows the format for Trim in each certified
database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

LTRIM(RTRIM(S))

DataJoiner

LTRIM(RTRIM(S))

Informix

TRIM(BOTH 1 FROM S)

Oracle

TRIM(S)

Redbrick

LTRIM(RTRIM(S))

SQL Server

LTRIM(RTRIM(S))

Tandem

{fn LTRIM({fn RTRIM(S)})}

Sybase

LTRIM(RTRIM(S))

Teradata

TRIM(BOTH FROM S)

Access

TRIM(S)

Trim

331

12

String Functions

MicroStrategy Analytical Functions Reference

Trim Left
Name
LTrim

Information returned
A string in which blanks on the left edge of the input string
have been removed.

Syntax
LTrim(S)
The table shows the format for Left trim in each certified
database.

332 Trim Left

Database

Format

DB2 UDB

LTRIM(S)

DataJoiner

LTRIM(S)

Informix

TRIM(LEADING FROM S)

Oracle

LTRIM(S1)

Redbrick

LTRIM(S)

SQL Server

LTRIM(S)

Tandem

{fn LTRIM(S)}

Sybase

LTRIM(S)

Teradata

TRIM(LEADING FROM S)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

String Functions

12

Trim Right
Name
RTrim

Information returned
A string in which blanks on the right edge of the input string
have been removed.

Syntax
RTrim(S)
The table shows the format for Right trim in each certified
database.

2003 MicroStrategy, Inc.

Database

Format

DB2 UDB

RTRIM(S)

DataJoiner

RTRIM(S)

Informix

TRIM(TRAILING FROM S)

Oracle

RTRIM(S)

Redbrick

RTRIM(S)

SQL Server

RTRIM(S)

Tandem

{fn RTRIM(S)}

Sybase

RTRIM(S)

Teradata

TRIM(TRAILING FROM S)

Trim Right

333

12

String Functions

MicroStrategy Analytical Functions Reference

Upper Case
Name
Upper

Information returned
A string in which all lower-case alphabetic characters have
been converted to upper case.

Syntax
Ucase(S)
The table shows the format for Upper case in each certified
database.

334 Upper Case

Database

Format

DB2 UDB

UCASE(S)

DataJoiner

UCASE(S)

Informix

UPPER(S)

Oracle

UPPER(S)

Redbrick

UPPER(S)

SQL Server

UPPER(S

Tandem

{fn UCASE(S)}

Sybase

UPPER(S)

Teradata

UPPER(S)

Access

UCASE(S)

2003 MicroStrategy, Inc.

A
DATABASE SUPPORT FOR
MICROSTRATEGY FUNCTIONS

Introduction
The tables in this appendix show the MicroStrategy 7i engine
functions supported by the various certified databases. The
information is presented by database, and, within each
database, by function type.
on database support of string and date/time
* Specifics
functions is not included in the information that
follows; please see the corresponding chapters in this
document for details.

2003 MicroStrategy, Inc.

335

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Access
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Sum

SUM(n)

Null and zero functions


Name

Notation

Null to zero)

||F( ISNULL(n), x, y )

Zero to null

||F( x=0, null, y )

DB2
Basic functions

336 Access

Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a


population)

STDDEV(n)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Basic functions
Sum

SUM(n)

Variance (of a population)

VAR(n)

Mathematical functions
Name

Notation

Absolute value

ABS

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2( n1, n2 )

Ceiling

CEIL

Cosine

COS

Cosine, hyperbolic

COSH

Degrees to radians (conversion of) DEGREES

2003 MicroStrategy, Inc.

Exponent

EXP

Floor

FLOOR

Logarithm, natural

LN

Logarithm, base 10

LOG10

Mod

MOD( n1, n2 )

Power

POWER( n1, n2 )

Radians to degrees (conversion


of)

RADIANS

Round

ROUND

Sine

SIN

Sine, hyperbolic

SINH

Square root

SQRT

Tangent

TAN

Tangent, hyperbolic

TANH

Truncate

TRUNCATE(n)

DB2

337

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Null and zero functions


Name

Notation

Null to zero

Value(n)

Zero to null

CASE

OLAP functions
Name

Notation

Average, moving

Avg(n1) Over(n2)

Average, running

Avg(n1) Over(n2)

Count, moving

Count(n1) Over(n2)

Count, running

Count(n1) Over(n2)

Max, moving

Max(n1) Over(n2)

Max, running

Max(n1) Over(n2)

Min, moving

Min(n1) Over(n2)

Min, running

Min(n1) Over(n2)

Standard deviation, moving


(population)

Stddev(n1) Over(n2)

Standard deviation, running


(population)

Stddev(n1) Over(n2)

Sum, moving

Sum(n1) Over(n2)

Sum, running

Sum(n1) Over(n2)

Statistical functions

338 DB2

Name

Notation

Coefficient of determination (regr.


slope)

REGR_R2

Correlation

CORRELATION( x, y )

Covariance

COVARIANCE( x, y )

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Statistical functions
Linear regression intercept

REGR_INTERCEPT

Linear regression slope

REGR_SLOPE

Datajoiner
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a


population)

STDDEV(n)

Sum

SUM(n)

Variance (of a population)

VAR(n)

Mathematical functions
Name

Notation

Absolute value

ABS

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2( n1, n2 )

Ceiling

CEIL

Cosine

COS

Degrees to radians (conversion of) DEGREES


Exponent

2003 MicroStrategy, Inc.

EXP

Datajoiner

339

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Mathematical functions
Floor

FLOOR

Logarithm, natural

LN

Logarithm, base 10

LOG10

Mod

MOD( n1, n2 )

Power

POWER( n1, n2 )

Radians to degrees (conversion


of)

RADIANS

Round

ROUND

Sine

SIN

Square root

SQRT

Tangent

TAN

Truncate

TRUNCATE(n)

Null and zero functions


Name

Notation

Null to zero

Value(n)

Zero to null

CASE

Informix
Basic functions

340 Informix

Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a sample)

STDEV

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Basic functions
Sum

SUM(n)

Variance (of a sample)

VARIANCE

Mathematical functions
Name

Notation

Absolute value

ABS

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2

Cosine

COS

Exponent

EXP

Logarithm, natural

LOGN

Logarithm, base 10

LOG10

Mod

MOD

Power

POW

Round

ROUND

Sine

SIN

Square root

SQRT

Tangent

TAN

Truncate

TRUNC(n)

Null and zero functions

2003 MicroStrategy, Inc.

Name

Notation

Null to zero

NLV(n)

Zero to null

CASE

Informix

341

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Oracle
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

First

FIRST

Last

LAST

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a


population)

STDDEV_POP

Standard deviation (of a sample)

STDDEV

Sum

SUM(n)

Variance (of a population)

VAR_POP

Variance (of a sample)

VARIANCE

Mathematical functions

342 Oracle

Name

Notation

Absolute value

ABS(n)

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2

Ceiling

CEIL(n)

Cosine

COS(n)

Cosine, hyperbolic

COSH(n)

Exponent

EXP(n)

Floor

FLOOR(n)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Mathematical functions
Logarithm, natural

LN(n)

Logarithm, base 10

LOG(n)

Mod

MOD( n1, n2 )

Power

POWER( n1, n2 )

Round

ROUND( n1, n2 )

Sine

SIN(n)

Sine, hyperbolic

SINH(n)

Square root

SQRT(n)

Tangent

TAN(n)

Tangent, hyperbolic

TANH(n)

Truncate

TRUNC(n)

Null and zero functions


Name

Notation

Null to zero

NLV(n)

OLAP functions

2003 MicroStrategy, Inc.

Name

Notation

Average, moving

Avg(n1) Over(n2)

Average, running

Avg(n1) Over(n2)

Count, moving

Count(n1) Over(n2)

Count, running

Count(n1) Over(n2)

Max, moving

Max(n1) Over(n2)

Max, running

Max(n1) Over(n2)

Min, moving

Min(n1) Over(n2)

Min, running

Min(n1) Over(n2)

Oracle

343

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

OLAP functions
Standard deviation, moving
(sample)

Stddev(n1) Over(n2)

Standard deviation, running


(sample)

Stddev(n1) Over(n2)

Sum, moving

Sum(n1) Over(n2)

Sum, running

Sum(n1) Over(n2)

Statistical functions
Name

Notation

Coefficient of determination (regr.


slope)

REGR_R2

Correlation

CORR

Covariance

COVAR_POP

Linear regression intercept

REGR_INTERCEPT

Linear regression slope

REGR_SLOPE

Redbrick
Basic functions

344 Redbrick

Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Sum

SUM(n)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Mathematical functions
Name

Notation

Absolute value

ABS

Ceiling

CEIL

Exponent

EXP

Floor

FLOOR

Logarithm, natural

LN

Logarithm, base 10

LOG10

Power

POWER( n1, n2 )

Square root

SQRT

Null and zero functions


Name

Notation

Null to zero

IFNULL(n)

Zero to null

NULLIF(n)

OLAP functions

2003 MicroStrategy, Inc.

Name

Notation

Average, moving

MOVINGAVG

Redbrick

345

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

SQL Server
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

First

FIRST

Last

LAST

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a


population)

STDEVP

Standard deviation (of a sample)

STDEV

Sum

SUM(n)

Variance (of a population)

VARP

Variance (of a sample)

VAR

Mathematical functions
Name

Notation

Absolute value

ABS

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2( n1, n2 )

Ceiling

CEIL

Cosine

COS

Degrees to radians (conversion of) DEGREES

346 SQL Server

Exponent

EXP

Floor

FLOOR

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Mathematical functions
Logarithm, natural

LOG

Logarithm, base 10

LOG10

Power

POWER

Radians to degrees (conversion


of)

RADIANS

Round

ROUND

Sine

SIN

Square root

SQRT

Tangent

TAN

Null and zero functions


Name

Notation

Null to zero

ISNULL(n)

Zero to null

NULLIF(n)

Sybase
Basic functions

2003 MicroStrategy, Inc.

Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Sum

SUM(n)

Sybase

347

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Mathematical functions
Name

Notation

Absolute value

ABS

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2( n1, n2 )

Ceiling

CEILING

Cosine

COS

Degrees to radians (conversion of) DEGREES


Exponent

EXP

Floor

FLOOR

Logarithm, natural

LOG

Logarithm, base 10

LOG10

Power

POWER

Radians to degrees (conversion


of)

RADIANS

Round

ROUND

Sine

SIN

Square root

SQRT

Tangent

TAN

Null and zero functions

348 Sybase

Name

Notation

Null to zero

ISNULL(n)

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Tandem
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a sample)

STDEV

Sum

SUM(n)

Variance (of a population)

VARIANCE

Mathematical functions
Name

Notation

Absolute value

ABS

Null and zero functions

2003 MicroStrategy, Inc.

Name

Notation

Null to zero

CASE

zero to null

CASE

Tandem

349

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Teradata
Basic functions
Name

Notation

Average

AVG(n)

Count

COUNT(n)

Maximum

MAX(n)

Minimum

MIN(n)

Standard deviation (of a


population)

STDDEV_POP(n)

Standard deviation (of a sample)

STDDEV_SAMP(n)

Sum

SUM(n)

Variance (of a population)

VAR_POP

Variance (of a sample)

VAR_SAMP(n)

Mathematical functions

350 Teradata

Name

Notation

Absolute value

ABS(n)

Arc cosine

ACOS

Arc sine

ASIN

Arc tangent

ATAN

Arc tangent 2

ATAN2

Cosine

COS

Cosine, hyperbolic

COSH

Exponent

EXP(n)

Logarithm, natural

LN(n)

Logarithm, base 10

LOG(n)

Mod

MOD(n)

Power

n1** n2

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Database Support for MicroStrategy Functions

Mathematical functions
Sine

SIN

Sine, hyperbolic

SINH

Square root

SQRT(n)

Tangent

TAN

Tangent, hyperbolic

TANH

Null and zero functions


Name

Notation

Null to zero

ZEROIFNULL

zero to null

NULLIFZERO

OLAP functions
Name

Notation

Average, moving

Avg(n1) Over(n2)

Difference, moving

Mdiff(n)

Count, running

Count(n1) Over(n2)

Sum, moving

Sum(n1) Over(n2)

Sum, running

Sum(n1) Over(n2)

Statistical functions

2003 MicroStrategy, Inc.

Name

Notation

Coefficient of determination (regr.


slope)

REGR_R2

Correlation

CORR( n1, n2 )

Covariance

COVARI_POP( n1, n2 )

Teradata

351

Database Support for MicroStrategy Functions

MicroStrategy Analytical Functions Reference

Statistical functions

352 Teradata

Kurtosis

KURTOSIS(n)

Linear regression intercept

REGR_INTERCEPT<independent
expression>, <dependent
expression>

Linear regression slope

REGR_SLOPE<independent
expression>, <dependent
expression>

Skew

SKEW(n)

2003 MicroStrategy, Inc.

INDEX
A
Abs 210
Access function support
basic 336
null and zero 336
Accrint 138
Accrintm 140
Acos 210
amount at maturity 141
analytical engine, the 16
ApplyAgg 204
ApplyComparison 204
ApplyLogic 204
ApplyOLAP 204
ApplySimple 204
arc cosine 210
arc sine 211
arc tangent 212, 213
Asin 211
Atan 212
Atan2 213
average 106
moving 241
running 249
Avg 106
2003 MicroStrategy, Inc.

AvgDev 266

B
balance
double-declining 156
fixed declining 161
variable declining 196
Banding 98
banding functions
band count 98
band size 98
banding in custom groups 99
banding points 99
examples 100
BandingC 98
BandingP 99
basic functions
Avg 106
Count 106
First 107
GeoMean 108
Greatest 109
Last 109
Least 110
Max 111
353

Index

Median 112
Min 112
Mode 113
Product 114
Stdev 116
Stdevp 115
Sum 117
Var 119
Varp 118
Beta distribution, inverse of 268
BetaDistribution 267
BinomialDistribution 269

C
cap
initial 324
Case 206
case
upper 334
Case Value 207
CaseV 207
Ceiling 214
ChiSquareDistribution 271
ChiSquareTest 273
combination 215
Combine 215
compound metric 2
Concat 322
ConcatBlank 323
concatenate 322
concatenate (with blank) 323
condition 2
Confidence 274
confidence interval 274
Correlation 276
Cos 216
Cosh 217

354

MicroStrategy Analytical Functions Reference

cosine 216
cosine, hyperbolic 217
Count 106
count
moving 242
running 250
Coupdaybs 147
Coupdays 149
Coupdaysnc 150
Coupncd 144
Coupnum 143
coupon date
next 144
previous 146
coupon period
beginning to settlement 147
number of days with settlement 149
settlement to next 150
coupon, number payable between settlement and maturity 143
Couppcd 146
Covariance 278
CritBinomial 279
criterion binomial 279
Cumipmt 151
Cumprinc 153
current date 122
current date and time 130
current time 131
CurrentDate 122
CurrentDateTime 130
CurrentTime 131

D
Datajoiner function support
basic 339
mathematical 339
null and zero 340
2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

date functions
CurrentDate 122
CurrentDateTime 130
CurrentTime 131
DayOfMonth 123
DayOfWeek 124
DayOfYear 125
Hour 132
MilliSecond 135
Minute 133
Month 127
Quarter 128
Second 134
Week 126
Year 129
day
of the month 123
of the week 124
of the year 125
DayOfMonth 123
DayOfWeek 124
DayOfYear 125
Db 161
DB2 function support
basic 336
mathematical 337
null and zero 338
OLAP 338
statistical 338
DDB 156
Degrees 218
degrees, conversion to 218
depreciation
straight line 191
sum of years digits 192
deviation
average 266
standard (population) 115, 305

2003 MicroStrategy, Inc.

Index

standard (sample) 115, 116


difference
moving 243
dimensionality. See level.
Disc 157
discount rate 157
distribution
beta 267
binomial 269
chi-square 271
chi-square, inverse of 272
exponential 280
f-probability 283
f-probability, inverse of 284
gamma 286
gamma, logarithm of 289
hypergeometric 290
lognormal 292, 293
lognormal, inverse of 294
negative binomial 296
normal cumulative 296, 297
normal cumulative, inverse of 298
Poisson 302
standard normal cumulative 116, 308
standard normal cumulative, inverse
of 309
t 310
t, inverse of 311
Weibull 319
dollar price
converted from decimal to
fraction 155
converted from fraction to
decimal 154
Dollarde 154
Dollarfr 155
Duration 158
duration

355

Index

Macauley 158
modified Macauley 169

E
Effect 159
engine
analytical, the 16
query, the 16
SQL, the 16
equity
t-bill 193
error of estimates
standard 306
estimates
standard error 306
Exp 218
exponent 218
ExponentialDistribution 280
ExpWghMovingAvg 238
ExpWghRunningAvg 238

F
Factorial 219
FDistribution 283
finance functions
Accrint 138
Coupdaybs 147
Coupdays 149
Coupdaysnc 150
Coupncd 144
Coupnum 143
Couppcd 146
Cumipmt 151
Cumprinc 153
Db 161
DDB 156
Disc 157
356

MicroStrategy Analytical Functions Reference

Dollarde 154
Dollarfr 155
Duration 158
Effect 159
Fv 162
Fvschedule 163
Intrate 165
Ipmt 164
IRR 168
Mduration 169
MIRR 171
Nominal 173
Nper 174
NPV 172
Oddfprice 175
Oddfyield 177
Oddlprice 179
Oddlyield 181
Pmt 182
Ppmt 190
Price 188
Pricedisc 186
Pricemat 185
Pv 183
Rate 166
Received 141
Sln 191
Syd 192
Tbilleq 193
Tbillprice 194
Tbillyield 195
VDB 196
Yield 197
Yielddisc 201
Yieldmat 199
First 107
first occurrence
position 327

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

FirstInRange 239
Fisher 281
Fisher transformation 281
Fisher transformation, inverse of 282
fixed declining balance 161
Floor 220
FTest 285
f-test 285
function support
Access 336
Datajoiner 339
DB2 336
Informix 340
Oracle 342
Redbrick 344
SQL Server 346
Sybase 347
Tandem 349
Teradata 350
future value 162
Fv 162
Fvschedule 163

G
Gamma distribution, inverse of 288
GammaDistribution 286
GammaDistributionLn 289
GeoMean 108
geometric mean 108
Greatest 109

H
Heteroscedastic t-test 316
HeteroscedasticTTest 316
Homoscedastic t-test 316
HomoscedasticTTest 316
Hour 132
2003 MicroStrategy, Inc.

Index

HypergeometricDistribution 290

I
independence
chi-square test 273
Informix function support
basic 340
mathematical 341
null and zero 341
InitCap 324
initial cap 324
Int 221
integer 221
Intercept 291
interception, point of 291
interest
accrued 138
at maturity finance functions
Accrintm 140
cumulative paid 151
effective annual rate 159
nominal annual rate 173
payment 164
rate (per period) 166
interest rate 165
Internal functions
ApplyAgg 204
ApplyComparison 204
ApplyLogic 204
ApplyOLAP 204
ApplySimple 204
Case 206
CaseV 207
pass-through 203
international support xxiii
Intrate 165
InverseBetaDistribution 268

357

Index

InverseChiDistribution 272
InverseFDistribution 284
InverseFisher 282
InverseGammaDistribution 288
InverseLogNormalDistribution 294
InverseNormDistribution 298
InverseNormSDistribution 309
InverseTDistribution 311
investment periods, number of 174
Ipmt 164
IRR 168
IsNotNull 234
IsNull 235

K
Kurtosis 292

L
Last 109
LastInRange 240
Least 110
left string 328
left trim 332
LeftStr 328
Length 325
level 2
Ln 222
Log 221
Log10 222
logarithm
(all bases) 221
base 10 222
natural 222
LognormalDistribution 293
Lower 326
lower case 326
LTrim 332
358

MicroStrategy Analytical Functions Reference

M
Macauley duration 158
mathematical functions
Abs 210
Acos 210
Asin 211
Atan 212
Atan2 213
Ceiling 214
Combine 215
Cos 216
Cosh 217
Degrees 218
Exp 218
Factorial 219
Floor 220
Int 221
Ln 222
Log 221
Log10 222
Power 224
Quotient 225
Radians 225
Randbetween 226
Sin 227
Sinh 227
Sqrt 228
Tan 229
Tanh 230
Trunc 231
Max 111
Maximum 111
maximum
moving 244
running 251
Mduration 169
MeanTTest 313

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Median 112
metrics
aggregation levels 14
attributes and elements 14
compound 2
condition 2
dimensionality. See level.
facts in definitions 3
filters 15
level (dimensionality) 2
notation and syntax 12
simple 2
terminology 11
transformation 2
transformations 15
using filters 15
MicroStrategy 7i engine
function access xvi
function types xv
functions 16
handling calculations 17
structure 16
syntax notation xvi
MilliSecond 135
Min 112
minimum 112
moving 245
running 252
Minute 133
MIRR 171
Mode 113
modified Macauley duration 169
Month 127
month of the year 127
moving
average 241
average, exponential weight 238
count 242

2003 MicroStrategy, Inc.

Index

difference 243
maximum 244
minimum 245
standard deviation (population) 246
standard deviation (sample) 247
sum 248
MovingAvg 241
MovingCount 242
MovingDifference 243
MovingMax 244
MovingMin 245
MovingStdev 247
MovingStDevp 246
MovingSum 248

N
NegativeBinomialDistribution 296
net value, present 172
Nominal 173
NormalDistribution 297
Nper 174
NPV 172
NTile 258
n-tile 258
NTile_S 259
n-tile_s 259
n-tile_VNTile_V 260
N-Tile_VS 261
NTile_VS 261
Null
is 235
is not 234
null and zero functions
IsNotNull 234
IsNull 235
NullToZero 236
ZeroToNull 236

359

Index

null to zero 236


NullToZero 236

O
occurrence
position of first 327
Oddfprice 175
Oddfyield 177
Oddlprice 179
Oddlyield 181
OLAP functions
ExpWghMovingAvg 238
ExpWghRunningAvg 238
FirstInRange 239
LastInRange 240
MovingAvg 241
MovingCount 242
MovingDifference 243
MovingMax 244
MovingMin 245
MovingStdev 247
MovingStDevp 246
MovingSum 248
RunningAvg 249
RunningCount 250
RunningMax 251
RunningMin 252
RunningStDev 254
RunningStDevp 253
RunningSum 255
Oracle function support
basic 342
mathematical 342
null and zero 343
OLAP 343
statistical 344

360

MicroStrategy Analytical Functions Reference

P
PairedTTest 314
pass-through functions
Apply statements 204
introduction 203
syntax 204
use 204
payment 182
Pearson 299
Pearson product moment correlation
coefficient 299
Pearson product moment correlation coefficient, square of 300
Percentile 262
Permut 301
permutation 301
Pmt 182
PoissonDistribution 302
Position 327
Power 224
Ppmt 190
Price 188
price
at maturity 185
discounted 186
odd first period 175
odd last period 179
per $100 face value 188
t-bill 194
Pricedisc 186
Pricemat 185
principal, cumulative paid 153
principle payment 190
Product 114
Pv 183

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Q
Quarter 128
quarter of the year 128
query engine, the 16
Quotient 225

R
Radians 225
radians, conversion to 225
Randbetween 226
random number 226
Rank 262, 263
rank
by percent 263
by value 262
rank and tile functions
NTile 258
NTile_S 259
NTile_V 260
NTile_VS 261
Percentile 262
Rank 262, 263
Rate 166
rate of return (internal) 168
rate of return (internal, modified) 171
Received 141
Redbrick function support
basic 344
mathematical 345
null and zero 345
OLAP 345
right string 329
right trim 333
RightStr 329
RSquare 300
RTrim 333
running

2003 MicroStrategy, Inc.

Index

average 249
average, exponential weight 238
count 250
maximum 251
minimum 252
standard deviation (population) 253
standard deviation (sample) 254
sum 255
RunningAvg 249
RunningCount 250
RunningMax 251
RunningMin 252
RunningStDev 254
RunningStDevp 253
RunningSum 255

S
Second 134
simple metric
condition 2
dimensionality. See level.
level 2
transformation 2
Sin 227
sine 227
sine, hyperbolic 227
Sinh 227
Skew 304
Sln 191
Slope 305
slope of a linear regression 305
Sortby parameter 237
SQL engine, the 16
SQL Server function support
basic 346
mathematical 346
null and zero 347

361

Index

Sqrt 228
square root 228
standard deviation
moving 246, 247
running 253, 254
Standardize 307
StandardNormalDistribution 308
statistical functions
AvgDev 266
BetaDistribution 267
BinomialDistribution 269
ChiSquareDistribution 271
ChiSquareTest 273
Confidence 274
Correlation 276
Covariance 278
CritBinomial 279
ExponentialDistribution 280
FDistribution 283
Fisher 281
FTest 285
GammaDistribution 286
GammaDistributionLn 289
HeteroscedasticTTest 316
HomoscedasticTTest 316
HypergeometricDistribution 290
Intercept 291
InverseBetaDistribution 268
InverseChiDistribution 272
InverseFDistribution 284
InverseFisher 282
InverseGammaDistribution 288
InverseLogNormalDistribution 294
InverseNormDistribution 298
InverseNormSDistribution 309
InverseTDistribution 311
Kurtosis 292
LognormalDistribution 293

362

MicroStrategy Analytical Functions Reference

MeanTTest 313
NegativeBinomialDistribution 296
NormalDistribution 297
PairedTTest 314
Pearson 299
Permut 301
PoissonDistribution 302
RSquare 300
Skew 304
Slope 305
Standardize 307
StandardNormalDistribution 308
SteYX 306
TDistribution 310
VarTest 318
WeibullDistribution 319
Stdev 116
Stdevp 115
SteYX 306
string
from left 328
from right 329
string functions
Concat 322
ConcatBlank 323
InitCap 324
LeftStr 328
Length 325
Lower 326
LTrim 332
Position 327
RightStr 329
RTrim 333
SubStr 330
Trim 331
Upper 334
SubStr 330
substring 330

2003 MicroStrategy, Inc.

MicroStrategy Analytical Functions Reference

Sum 117
sum
moving 248
running 255
support
international xxiii
Sybase function support
basic 347
mathematical 348
null and zero 348
Syd 192

T
Tan 229
Tandem function support
basic 349
mathematical 349
null and zero 349
tangent 229
tangent, hyperbolic 230
Tanh 230
Tbilleq 193
Tbillprice 194
Tbillyield 195
TDistribution 310
technical support xxiv
Teradata function support
basic 350
mathematical 350
null and zero 351
OLAP 351
statistical 351
test for independence
chi-square 273
transformation 2
Trim 331
trim

2003 MicroStrategy, Inc.

Index

left 332
right 333
Trunc 231
truncate 231
t-test
heteroscedastic 316
homoscedastic 316
mean 313
paired two-sample 314
two-sample 316

U
Upper 334
upper case 334

V
value
absolute 210
ceiling 214
first in range 239
floor 220
future (schedule) 163
last in range 240
present 183
value, future 162
Var 119
variance
of a population 118
of a sample 119
variance test 318
Varp 118
VarTest 318
VDB 196

W
Week 126

363

Index

MicroStrategy Analytical Functions Reference

week of the year 126


WeibullDistribution 319

Y
Year 129
Yield 197
yield
at maturity 199
odd first period 177
odd last period 181
on a discounted security 201
on a security 197
t-bill 195
Yielddisc 201
Yieldmat 199

Z
zero to null 236
ZeroToNull 236

364

2003 MicroStrategy, Inc.

Você também pode gostar