Recently I got a chance to identify how to use R analytics functions inside MicroStrategy from 921 versions. I believe it would help for some of the folks to look and use them as needed.
Please find below the steps to integrate the same.
How to Integrate R functions into MicroStrategy 9.2.1 or greater
MicroStrategy Version 9.2.1 or greater must be installed with MicroStrategy Architect.
Visual Studio 2010
Visual Studio 2010 with C/++ must be installed. Please note that Visual Studio Express does not support custom wizards, but the ‘FP Wizard’ is supported on all other Visual Studio packages (Professional, Ultimate, etc.). Note: Visual Studio 2005 is also supported, although Visual Studio 2005 is no longer supported by Microsoft.
MicroStrategy Function Plug-in Wizard
The MicroStrategy Function Plug-in Wizard (FPWizard) is a Visual Studio C++ Template for creating MicroStrategy Function Plug-ins, which allow the MicroStrategy Business Intelligence platform to execute a user’s own custom functions. More details about how to use the FP Wizard can be found using the FP Wizard’s On-line help (accessible by clicking the FP Wizard’s Help button in Visual Studio).
Once the FP Wizard is installed, a new template will be available for your C++ projects. New C++ projects can be created using this template and the FP Wizard will allow you to specify all the relevant details, such as capturing each function’s signature (inputs/outputs/properties). Once you finish entering the information about your function, the FP Wizard will create a C++ project with all code necessary for MicroStrategy to pass inputs to your functions and consume the results. All you need to do is add the function execution code, compile and deploy your DLL to MicroStrategy.
The FP Wizard installer can be downloaded from http://fpwizard.codeplex.com/.
For function plug-ins implemented using the R statistical environment, R can be installed from http://CRAN.R-project.org.
2. PROCESS OVERVIEW
1. User installs pre-requisites (MicroStrategy, Visual Studio, FP Wizard and R)
2. User creates a Visual C++ project using the MicroStrategy Function Plug-in Wizard
a. User specifies the inputs and output of the function
b. User specifies any function parameters
c. User provides the location of the R Script containing the function.
d. Repeat a-c for each additional functions to be included in the Function DLL.
3. User compiles the Visual C++ project which results in the Function DLL
4. User imports the Function DLL into MicroStrategy using MicroStrategy Desktop’s Function Import Utility
5. The new function is now ready to be used in metrics that can be deployed in MicroStrategy reports, scorecards, dashboards and other objects such as filters and custom groups.
3. STEPS TO IMPORT FUNCTION DLL
1. Open MicroStrategy Desktop
2. Go to ‘Schema’ menu and select ‘Import Functions’ option
3. Browse using the ‘…’ button to locate the DLL to import
4. Move the selected DLL from “Available functions” to “Add these functions to project”
5. Click OK to save the function to a folder called “My Functions” (if it doesn’t exist, the folder can be added by clicking the “new folder” icon in the upper right), then click OK
6. Update Schema (so the new function will become available)
4. STEPS TO METRIC BASED OFF NEW FUNCTION
1. Create a new metric and use the “Function Picker” button to select the newly imported function.
2. Browse to the “My Functions” folder and select the function.
3. Add neccesary parameters and configure the metric as usual. Once created, the metric can be deployed just like any other metric within the MicroStrategy Project.
How to use R Integration Pack in MicroStrategy 9.2.1 or higher?
In 2013, a new feature is introduced to deploy R Analytics to MicroStrategy easily – R Integration Pack. The R Integration Pack is an evolution of previous FPWizard, an alternative approach to deploying analytics from R to MicroStrategy. For more details regarding MicroStrategy Function Plug-in Wizard, refer to the following Technical Note in Knowledge Base:
R Integration Pack and its deployR utility provide the metric expression of each potential output. The metric expression can be pasted into any MicroStrategy metric editor for deploying the R Analytic to MicroStrategy for execution. Watch video below about how R Integration Pack works in MicroStrategy 9.3.1:
The following chart shows the differences between previous MicroStrategy R Function Plug-ins and R Integration Pack.
- MicroStrategy version 9.2.1 or higher must be installed. An exception is that to deploy a new R analytic as a derived metric in Visual Insight requires version 9.3.1.
- MicroStrategy Architect is necessary for the one-time addition of the common RScript functions.
- R must be installed on systems that will execute the R analytics deployed to MicroStrategy. This includes the MicroStrategy Intelligence Server and any MicroStrategy Desktop clients that execute R analytics as derived metrics. R is not required on other clients such MicroStrategy Web, MicroStrategy Mobile, MicroStrategy Visual Insight and MicroStrategy Office since they are consumers of analytics deployed to the MicroStrategy Intelligence Server.
- R can be installed from http://CRAN.R-project.org.
- If the R Analytic has dependencies on add-on packages that are not included standard with R, those packages must also added to the R installation on the MicroStrategy systems.
3. Download R Integration Pack
The R Integration Pack consists of two main components:
RScript Functions Installer: This installer adds a set of functions to MicroStrategy that are used for executing analytics in R. These functions are required to execute your R analytic using MicroStrategy. You can download the appropriate installer for your operating system from:http://rintegrationpack.codeplex.com/.
MicroStrategyR Package for R: This package contains an R-based utility called deployR that analyzes an R analytic to captures its “signature” and persists it in a comment block at the beginning of the R script. This signature describes the number and nature of each input and output along with other information related to its execution so that MicroStrategy can pass data to R, execute the analytic and deploy its results. This package is only required to prepare an R Script for execution by MicroStrategy by capturing the function signature into the header block. Once the script has been prepared, this package is not required for executing the prepared script. This package can be installed into your R environment just like any other R package using the CRAN repository, accessible from http://www.r-project.org/ website. Click CRAN, choose a mirror and search “MicroStrategyR” for the package name.
Following is a sample link: http://cran.r-project.org/web/packages/MicroStrategyR/index.html
4. Use deployR utility to create metrics expression
Assuming user already had their R script. DeployR Utility can add a description of user’s Analytic’s Signature to user’s R Script so it can be deployed to MicroStrategy. Follow below steps for high level guidance to use deploy R utility. For more help regarding R Integration Pack, refer to R Integration Pack User Guide available in http://rintegrationpack.codeplex.com/documentation.
Open R script in deployR utility.
- Make necessary changes to all your variables.
Persist your signature to RScript.
Copy your Metric Expression and paste in MicroStrategy Metric Editor.
Have a Happy Reading!!!!!
Have a Good Day!!