MicroStrategy ONE

Using Custom Plug-In Functions

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

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

For detailed information on individual functions, see Plug-In Package Functions and the Function Plug-in Wizard online help.

Creating User-Defined Plug-In Functions

Using the MicroStrategy Function Plug-In Wizard, you can define custom functions relevant to your business case scenarios. You can create individual functions or even entire function packages, such as the financial, mathematical, and statistical packages, provided by MicroStrategy. Guided by the wizard, you start by creating a Microsoft Visual C++ project with placeholders where you can add custom analytic code. After the new plug-in function is created, you need to launch MicroStrategy Developer to import it so it can be used for all the reports. As mentioned previously, once a function is imported, it will be used in the same way as any other standard MicroStrategy function.

For instructions on creating a plug-in function, see the Function Plug-in Wizard online help.

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

  • Designing: determines how to implement the analytical procedures into a computer algorithm.
  • Creating: creates the Microsoft Visual C++ project, which is used to build a library containing your algorithms.
  • Implementing: creates the code that embodies the algorithms and compiling this code into a library that is used by MicroStrategy.
  • Importing: adds the library to a MicroStrategy project so that its algorithms are available for use in the project.
  • Executing: creates new metrics that use the algorithms and using those metrics in a MicroStrategy report.

You can create the following types of functions:

  • Single-value functions
  • Group-value functions
  • OLAP functions

The datatypes of input arguments can be:

  • Numeric
  • Date
  • String

A plug-in function can contain more than one parameter. Supported datatypes for parameters include:

  • Byte
  • Short
  • Long
  • Float
  • Double
  • String (BSTR)
  • Bool
  • Date

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

  • FORECAST<n>(numeric_vector1) = numeric1
    • Aggregate function with a numeric vector as an input argument and a numeric scalar as an output argument.
    • One parameter, n, which is a long integer.
    • Given a series of values, and given that those values are each separated by one time interval, this function predicts what the value will be after n additional time intervals.

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

FORECAST<2>(UnitCost)

In this example, UnitCost includes a four year history of data, providing the following yearly values to the FORECAST function.

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

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

  • CUSTOMNUMBERFORMAT(numeric1) = string1
    • Simple function with numeric scalar as input argument and string scalar as output argument.
    • No parameters.
    • Transforms a number into a string representation of that number not supported by any of MicroStrategy's out-of-the-box metric format strings.

Example: CUSTOMNUMBERFORMAT(123456789) = '1 2345.6789'

To Install the Function Plug-In Wizard

  1. From ...\MicroStrategy\Workstation, click FPWizard.exe.
  2. Follow the prompts to install.

To Activate the Function Plug-In Wizard

  1. From the Start button, select Programs > Microsoft Visual Studio > Microsoft Visual C++.
  2. From the File menu, select New.
  3. On the Projects tab, select MicroStrategy Function Plug-in Wizard.
  4. Enter a name in the Project Name text box.

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

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

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

  1. In the master MicroStrategy online help, search for custom functions, or open the Creating and Modifying Additional Report Objects folder, expand the Metrics folder, and then expand the Using custom functions folder.
  2. Launch the Using custom functions topic. This topic contains a link to the Function Plug-in Wizard online help.
  3. Click the Function Plug-in Wizard on-line help link. The Function Plug-in Wizard online help opens in a new help window.