+ All Categories
Home > Documents > MicroStrategy Analitical Function Reference

MicroStrategy Analitical Function Reference

Date post: 09-Sep-2015
Category:
Upload: ilferrarista
View: 298 times
Download: 3 times
Share this document with a friend
Description:
Manual reference of the Analitical Function of MicroStrategy product
Popular Tags:
394
MICROSTRATEGY A NALYTICAL FUNCTIONS REFERENCE Version: 7.2.3 Document Number: 09410723
Transcript
  • 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 numberwith 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 otherperson. 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 EITHERMICROSTRATEGY INCORPORATED OR ANYONE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION, OR DISTRIBUTION OF THESOFTWARE OR DOCUMENTATION, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE, GOOD TITLE AND NONINFRINGMENT, QUALITY OR ACCURACY. THE ENTIRE RISK AS TO THE QUALITY ANDPERFORMANCE OF THE SOFTWARE AND DOCUMENTATION IS WITH YOU. SHOULD THE SOFTWARE OR DOCUMENTATION PROVEDEFECTIVE, YOU (AND NOT MICROSTRATEGY, INC. OR ANYONE ELSE WHO HAS BEEN INVOLVED WITH THE CREATION, PRODUCTION, ORDISTRIBUTION OF THE SOFTWARE OR DOCUMENTATION) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR, ORCORRECTION. SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TOYOU.

    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 accountof any claim for damage, including any lost profits, lost savings, or other special, incidental, consequential, or exemplary damages, including but not limitedto 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 andDocumentation, 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 anyother party. In addition, MicroStrategy, Inc. or any other person involved in the creation, production, or distribution of the Software shall not be liable forany claim by you or any other party for damages arising from the use, inability to use, quality, or performance of such Software and Documentation, basedupon principles of contract warranty, negligence, strict liability for the negligence of indemnity or contribution, the failure of any remedy to achieve itsessential 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 consequentialdamages, 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 entityof such revision. Copying, duplicating, selling, or otherwise distributing any part of the Software or Documentation without prior written consent of anauthorized representative of MicroStrategy, Inc. are prohibited. U.S. Government Restricted Rights. It is acknowledged that the Software andDocumentation were developed at private expense, that no part is public domain, and that the Software and Documentation are Commercial ComputerSoftware provided with RESTRICTED RIGHTS under Federal Acquisition Regulations and agency supplements to them. Use, duplication, or disclosureby 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 atDFAR 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 withrespect 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, MicroStrategyBroadcaster Server, MicroStrategy Business Intelligence Platform, MicroStrategy Consulting, MicroStrategy CRM Applications, MicroStrategy CustomerAnalyzer, 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, MicroStrategyNarrowcast 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 ApplicationManagement, 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, PersonalizedIntelligence Portal, Query Tone, Quickstrike, Rapid Application Development, Strategy.com, Telepath, Telepath Intelligence, Telepath Intelligence (andDesign), The E-Business Intelligence Platform, The Foundation For Intelligent E-Business, The Integrated Business Intelligence Platform Built For TheEnterprise, 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 oftheir 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 copyrightedtechnologies:

    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 UnicodeCopyright 1999-2003 Compaq Computer CorporationCopyright 1999-2003 Hewlett-Packard CompanyCopyright 1999-2003 IBM CorporationCopyright 1999-2003 Hummingbird Communications Ltd.Copyright 1999-2003 Silicon Graphics, Inc.Copyright 1999-2003 Sun Microsystems, Inc.Copyright 1999-2003 The Open GroupAll rights reserved.Real Player and RealJukebox are included under license from Real Networks, Inc. Copyright 1999-2003. All rights reserved.

  • 2003 MicroStrategy, Inc. iii

    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

  • Contents MicroStrategy Analytical Functions Reference

    iv 2003 MicroStrategy, Inc.

    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

  • MicroStrategy Analytical Functions Reference Contents

    2003 MicroStrategy, Inc. v

    4. Date Functions 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

  • Contents MicroStrategy Analytical Functions Reference

    vi 2003 MicroStrategy, Inc.

    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

  • MicroStrategy Analytical Functions Reference Contents

    2003 MicroStrategy, Inc. vii

    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

  • Contents MicroStrategy Analytical Functions Reference

    viii 2003 MicroStrategy, Inc.

    8. Null and Zero

    Functions

    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

  • MicroStrategy Analytical Functions Reference Contents

    2003 MicroStrategy, Inc. ix

    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

  • Contents MicroStrategy Analytical Functions Reference

    x 2003 MicroStrategy, Inc.

    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

  • MicroStrategy Analytical Functions Reference Contents

    2003 MicroStrategy, Inc. xi

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

    Oracle ........................................................................................ 342

    Redbrick..................................................................................... 344

    SQL Server ................................................................................ 346

    Sybase....................................................................................... 347

    Tandem...................................................................................... 349

    Teradata .................................................................................... 350

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

  • Contents MicroStrategy Analytical Functions Reference

    xii 2003 MicroStrategy, Inc.

  • 2003 MicroStrategy, Inc. xiii

    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

    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.

  • Preface MicroStrategy Analytical Functions Reference

    xiv Who Should Use this Guide 2003 MicroStrategy, Inc.

    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.

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. About this Book xv

    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:

    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

  • Preface MicroStrategy Analytical Functions Reference

    xvi About this Book 2003 MicroStrategy, Inc.

    Syntax notation

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

    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.

    Character Parameter type

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

    S String. Specific data type depends on the database.

    Examples: CHAR, VCHAR, TEXT.

    D Date. Specific data type depends on the database.

    Examples: DATE, DATETIME, TIMESTAMP.

    T Time. Specific data type depends on the database.

    Examples: TIME, DATETIME, TIMESTAMP.

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. Typographical standards xvii

    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.

    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.

    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

    calculations

    code samples

    registry keys

    path and file names

    URLs

    messages displayed in the screen

    UPPERCASE keyboard command key (such as ENTER)

    shortcut key (such as CTRL+V)

    + A keyboard command that calls for the use of more

    than one key (for example, SHIFT+F1)

  • Preface MicroStrategy Analytical Functions Reference

    xviii Typographical standards 2003 MicroStrategy, Inc.

    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:

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. Typographical standards xix

    The aggregation level is the level of calculation for the metric.

    Notes and warnings

    This note icon indicates helpful information.

    This warning icon calls your attention to very 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.

  • Preface MicroStrategy Analytical Functions Reference

    xx Resources 2003 MicroStrategy, Inc.

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

    Adobe Acrobat Reader is required to view these 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.

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. Resources xxi

    If bookmarks are not visible on the left side of an Acrobat 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

    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

  • Preface MicroStrategy Analytical Functions Reference

    xxii Resources 2003 MicroStrategy, Inc.

    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

    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

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. International support xxiii

    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.

  • Preface MicroStrategy Analytical Functions Reference

    xxiv User assistance 2003 MicroStrategy, Inc.

    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

    A technical administrator in your organization can probably help you resolve some of your issues immediately.

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. User assistance xxv

    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.

  • Preface MicroStrategy Analytical Functions Reference

    xxvi User assistance 2003 MicroStrategy, Inc.

    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: [email protected]

    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: [email protected]

    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: [email protected]

    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: [email protected]

    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: [email protected]

    Web: http://support.microstrategy.com

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. User assistance xxvii

    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:

    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

  • Preface MicroStrategy Analytical Functions Reference

    xxviii User assistance 2003 MicroStrategy, Inc.

    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.

  • MicroStrategy Analytical Functions Reference Preface

    2003 MicroStrategy, Inc. Feedback xxix

    Feedback

    Please send any comments or suggestions about user documentation for MicroStrategy 7i products to:

    [email protected]

    Send suggestions for product enhancements to:

    [email protected]

    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.

  • Preface MicroStrategy Analytical Functions Reference

    xxx Feedback 2003 MicroStrategy, Inc.

  • 2003 MicroStrategy, Inc. 1

    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:

    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 Reference1

    2 Metrics in MicroStrategy 7i 2003 MicroStrategy, Inc.

    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){~+}

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 3

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

  • Overview MicroStrategy Analytical Functions Reference1

    4 Metric formulae 2003 MicroStrategy, Inc.

    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:

    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

    n

    n

    i

    ixxxxfy

    ...)(21

    1

    x

    )(xfy

    sigma

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 5

    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,

    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.

    n

    i

    ixfy

    1

    )(x

  • Overview MicroStrategy Analytical Functions Reference1

    6 Metric formulae 2003 MicroStrategy, Inc.

    Example 3:

    Consider a function that is defined as:

    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:

    which is the same as

    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.

    )()( 1 xx AvgDevn

    xx

    fy

    n

    i

    i

    2

    11

    2

    2

    11

    2

    111),(n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    ii

    yynxxn

    yxyxn

    fz yx

    2

    11

    2

    2

    11

    2

    111),(n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    i

    n

    i

    ii

    yynxxn

    yxyxn

    RSquare yx

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 7

    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:

    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:

    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]

    y

    xyxfz ),(

    875.08

    7z

  • Overview MicroStrategy Analytical Functions Reference1

    8 Metric formulae 2003 MicroStrategy, Inc.

    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.

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 9

    Relative function

    Consider the following examples of relative functions.

    Example 8:

    Consider the following mapping.

    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:

    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.

    65

    46

    34

    20

    12

    20

    12

    7

    )(

    19

    12

    14

    8

    12

    8

    5

    7

    8,12,3

    7,12,3

    6,12,3

    5,12,3

    4,12,3

    3,11,3

    2,11,3

    1,11,3

    13

    8,12,3

    7,12,3

    6,12,3

    5,12,3

    4,12,3

    3,11,3

    2,11,3

    1,11,3

    13

    aa

    aa

    aa

    aa

    aa

    aa

    aa

    aa

    RunningSumAA

    aa

    aa

    aa

    aa

    aa

    aa

    aa

    aa

    AA yzy

    k

    i

    ikyz

    1

  • Overview MicroStrategy Analytical Functions Reference1

    10 Metric formulae 2003 MicroStrategy, Inc.

    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 , where 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: , , and tabs, where , and 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> (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.

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 11

    All functions have at least one 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.

  • Overview MicroStrategy Analytical Functions Reference1

    12 Metric formulae 2003 MicroStrategy, Inc.

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

    1The 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:

    fu n c t io n

    fu n c t io n

    p a ram e te r

    fa c t

    a g g reg a t io n

    le v e l

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

    f ilte r

    t ra n s fo rm a t io n

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 13

    In the in the metric syntax diagram,

    AggregationFunction is the name of the function being used

    is a function parameter (see description below)

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

    {~+} denotes the metric aggregation level (see description below)

    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.

  • Overview MicroStrategy Analytical Functions Reference1

    14 Metric formulae 2003 MicroStrategy, Inc.

    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:

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

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. Metric formulae 15

    In general, an aggregation level has a prefix, which can be either e or !, and a suffix, which can be +, *, %, or . The following applies to the use of aggregation-level symbols:

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

  • Overview MicroStrategy Analytical Functions Reference1

    16 The MicroStrategy 7i engine 2003 MicroStrategy, Inc.

    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

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. How Intelligence Server uses functions 17

    Handling of MicroStrategy 7i functions that are not 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.

    If a database platform does not support a given function 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:

    Simple metric

    Simple metric where formula is based on metrics

    New subtotal

  • Overview MicroStrategy Analytical Functions Reference1

    18 How Intelligence Server uses functions 2003 MicroStrategy, Inc.

    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([Fact]) { ~+}|TR|

    Since 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([Fact]) {~+}|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 {~+}|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:

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. How Intelligence Server uses functions 19

    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

  • Overview MicroStrategy Analytical Functions Reference1

    20 How Intelligence Server uses functions 2003 MicroStrategy, Inc.

    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:

    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.

    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]

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroStrategy, Inc. How Intelligence Server uses functions 21

    In the previous example, the dimensionality of all metrics is defined as {~+} (this is equivalent to {~+} 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

  • Overview MicroStrategy Analytical Functions Reference1

    22 How Intelligence Server uses functions 2003 MicroStrategy, Inc.

    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.

    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.

    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

  • MicroStrategy Analytical Functions Reference Overview 1

    2003 MicroSt


Recommended