Skip to main content

mstrio – Python and R wrappers for the MicroStrategy

mstrio – Python and R wrappers for the MicroStrategy REST APIs


Connecting to MicroStrategy 

Create a connection to the Intelligence Server using Connection() and  connect() in Python and R, respectively. Required arguments for the  Connection() function are the URL for the MicroStrategy REST API server, MicroStrategy Intelligence Server username and password, as well as the MicroStrategy project name. By default, the  connect() function anticipates your MicroStrategy Intelligence Server username and password. LDAP authentication is also supported. Use the optional argument  login_mode=16  in the  connect() function for LDAP authentication. 


Extract data from cubes and reports 

To extract data from MicroStrategy cubes and reports, use the  get_cube() and  get_report() functions. Use your connection object and the ID for the cube or report that you are fetching. You can get the ID by navigating to the cube or report within MicroStrategy Web, right-clicking on the desired cube, and selecting Properties. Alternatively, you can use MicroStrategy Developer in a similar manner.  The  get_cube() and  get_report() functions will return a data frame with the requested data. 


Upload data to MicroStrategy 

Create a new in-memory dataset with the create_dataset() function. You'll need to provide a name for your cube, as well as a name for the table that will contain the data. At this time, only one table per cube is supported. The create_cube() function will return the datasetID and tableID, which can be used to update a dataset with new data. 


Add or update a dataset with new data 

Once a dataset has been created, you can both update the data within the cube and add new data to it with the  update_dataset() function. Note that you'll need to pass in both the datasetID and tableID for the target dataset and table within the dataset, respectively. These are returned by the  create_dataset() function. 
The  update_policy  parameter controls the update behavior. Currently supported update operations are: 
  • add (inserts entirely new data) 
  • update (updates existing data) 
  • upsert (simultaneously updates existing data and inserts new data) 
  • replace (truncates and replaces the data)
This Knowledge Base article introduces "mstrio," Python and R packages which provide an interface for the MicroStrategy REST APIs. With a few lines of code, data scientists can extract data from cubes and reports and publish entirely new datasets for consumption by other analysts. 
This provides data scientists access to trusted, operational business data using Python and R, which is used in an overwhelming number of data science projects today. With mstrio, data scientists can quickly push their findings into a MicroStrategy dataset, enabling decision-makers to act on the insights. 

Connecting to MicroStrategy 

Create a connection to the Intelligence Server using Connection() and  connect() in Python and R, respectively. Required arguments for the  Connection() function are the URL for the MicroStrategy REST API server, MicroStrategy Intelligence Server username and password, as well as the MicroStrategy project name. By default, the  connect() function anticipates your MicroStrategy Intelligence Server username and password. LDAP authentication is also supported. Use the optional argument  login_mode=16  in the  connect() function for LDAP authentication. 

Extract data from cubes and reports 

To extract data from MicroStrategy cubes and reports, use the  get_cube() and  get_report() functions. Use your connection object and the ID for the cube or report that you are fetching. You can get the ID by navigating to the cube or report within MicroStrategy Web, right-clicking on the desired cube, and selecting Properties. Alternatively, you can use MicroStrategy Developer in a similar manner.  The  get_cube() and  get_report() functions will return a data frame with the requested data. 

Upload data to MicroStrategy 

Create a new in-memory dataset with the create_dataset() function. You'll need to provide a name for your cube, as well as a name for the table that will contain the data. At this time, only one table per cube is supported. The create_cube() function will return the datasetID and tableID, which can be used to update a dataset with new data. 

Add or update a dataset with new data 

Once a dataset has been created, you can both update the data within the cube and add new data to it with the  update_dataset() function. Note that you'll need to pass in both the datasetID and tableIDfor the target dataset and table within the dataset, respectively. These are returned by the  create_dataset() function. 
The  update_policy  parameter controls the update behavior. Currently supported update operations are: 
  • add (inserts entirely new data) 
  • update (updates existing data) 
  • upsert (simultaneously updates existing data and inserts new data) 
  • replace (truncates and replaces the data). 

Comments

Post a Comment

Popular posts from this blog

MicroStrategy URL API Parameters

MicroStrategy URL Structure The following table summarizes the root URL structure used for every request to MicroStrategy Web. Environment Main Application URL Administration URL J2EE http://webserver/MicroStrategy/servlet/mstrWeb http://webserver/MicroStrategy/servlet/mstrWebAdmin .NET http://webserver/MicroStrategy/asp/Main.aspx http://webserver/MicroStrategy/asp/Admin.aspx Every request sent to MicroStrategy Web calls a central controller. Parameters are appended to  Main.aspx  or  mstrWeb  (in a .NET and J2EE environment, respectively) to indicate to the controller how the request should be internally forwarded and handled. The following examples show a URL for accessing a MicroStrategy folder when the user does not have an existing session. The URL contains not only the parameters needed to connect to MicroStrategy Web, but also the parameters needed to log on and create a session. J2EE environment: <a href="http:...

Case functions Microstrategy

Ca se functions Microstrategy Case functions return specified data in a SQL query based on the evaluation of user-defined conditions. In general, a user specifies a list of conditions and corresponding return values. Case This function evaluates multiple expressions until a condition is determined to be true, then returns a corresponding value. If all conditions are false, a default value is returned.  Case  can be used for categorizing data based on multiple conditions. This is a single-value function. Syntax Case ( Condition1 ,  ReturnValue1 ,  Condition2 , ReturnValue2 ,...,  DefaultValue ) Example Case(([Total Revenue] < 300000), 0, ([Total Revenue] < 600000), 1, 2) sum(Case (Day@DESC in (“Sat”,”Sun”), Sales, 0) {~+} Sum(Case(Category@DESC In("Books","Electronics"),Revenue,0)){~+} CaseV (case vector) CaseV  evaluates a single metric and returns different values according to the results. It can be used to perfo...

RunningSum calculation only on the metric subtotal in MicroStrategy

RunningSum calculation only on the metric subtotal in MicroStrategy Here are the series of steps to setup report objects in which metrics and subtotals so only the  subtotal field  will contain the  RunningSum  and the  regular metric values  will be  standard sum values . 1) Create Metric 1 which is the sum of the fact that is to be in the columns. 2) Create Metric2 as the RunningSum of Metric1.  NOTE:  The  sortby  parameter for the RunningSum should be set to whichever attribute you want the report sorted by. 3) Create Metric3 as Metric1 + (Metric2 x 0) 4) Create a new subtotal called "Max" which is defined as Max() 5) On the Subtotals/Aggregation tab for Metric 3, set the Total subtotal function to be "Max" and select the check box for "Allow Smart Metric" 6) Create the desired report and place the 3 metrics on the report.  NOTE:  Only Metric3 is required on the gri...

Microstrategy Custom number formatting symbols

Custom number formatting symbols If none of the built-in number formats meet your needs, you can create your own custom format in the Number tab of the Format Cells dialog box. Select  Custom  as the Category and create the format using the number format symbols listed in the table below. Each custom format can have up to four optional sections, one each for: Positive numbers Negative numbers Zeros Text Each section is optional. Separate the sections by semicolons, as shown in the example below: #,###;(#,###);0;"Error: Entry must be numeric" For more examples, see  Custom number formatting examples . To jump to a section of the formatting symbol table, click one of the following: Numeric symbols Character/text symbols Date and time symbols Text color symbols Currency symbols Conditional symbols Numeric symbols For details on how numeric symbols apply to the Big Decimal data type, refer to the  Project Design Guide . ...

Best Practices for using images in Microstrategy reports

Using images in Microstrategy reports On the I-Server we copy the images to the following folders: - Program Files (x86)\MicroStrategy\Developer\Images - Program Files (x86)\MicroStrategy\IntelligenceServer\Images - Program Files (x86)\Common Files\MicroStrategy\images To reference an image using relative path, the following locations are required to store the image in order to display in multiple MicroStrategy products.    Relative path sample: images/ logo.jpg To display images on: MicroStrategy Desktop, Web, Mobile, Distribution Services: * Additional Adobe Flash security rule applies when displaying images on Flash Dashboard For image to display on MicroStrategy Web Services:   Note: It is recommended that HTTP path should be used for reference image. User should consider using HTTP path to reference image and store image in an client accessible server for easier maintain and upgrading purpose ...

Control the display of null and zero metric values

Show   Control the display of null and zero metric values in a grid report You can determine how to display or hide rows and columns in a grid report that consist only of null or zero metric values. You can have MicroStrategy hide the rows and columns in the following ways: Hide rows and columns that consist only of null metric values Hide rows and columns that consist only of zero metric values Hide rows and columns that consist only of null or zero metric values (default) Once you have defined how MicroStrategy hides null and zero metric values in the grid, you can quickly show or hide the grid using the Hide Nulls/Zeros option in the Data menu, as described below, or by clicking the  Hide Nulls/Zeros  icon  in the Data toolbar. To determine how null and zero metric values are displayed or hidden in a grid report Open the report in Edit mode. From the  Tools  menu, select  Report Options . The Report Options...

Multi-Select Drop Down Selector with Apply Button

Multi-Select Drop Down Selector with  OK Button  When creating a Report Services Document, you may want to create a drop down selector to save space, but also would like the drop down to be a multi-selector with OK/Apply button. Below are instructions to achieve this in a Report Services Document.  Steps to Create: 1. Right click on your drop down selector and choose Properties and Formatting 2. Navigate to the Layout Tab 3. In the layout tab, click "Allow multiple selections". It will  not  indicate that the check box is enabled, but this step is mandatory.  3. Next, navigate to the Theme tab. Choose the  L ight Theme  from the drop down menu and click the Apply button. 4) Next, change the Theme back to  None  and click Apply. 4. When you return to the Layout tab, you will see the checkbox for  Allow multiple selections  is now checked.  

Configure a report for use with Bulk Export in MicroStrategy

Configure a report for use with Bulk Export in MicroStrategy The Bulk Export feature enables a large report to be saved as a delimited text file. Using this feature, it is possible to retrieve result sets from a large dataset without having to load the entire dataset into memory. PS:  Once a report is setup for bulk export it cannot be used as a regular report. So if the report needs to be run as a normal report and as a bulk export report, the first step is to make a copy of the report for use with bulk export. Configure Bulk Export Bulk Export options are only available in MicroStrategy Developer. Open a 3-tier connection using MicroStrategy Developer and edit the desired report. Go to 'Data' on the top menu bar. Select 'Configure Bulk Export': Specify any additional desired configuration options. General Settings Bulk export database instance : This is the database instance to use to store the bulk export results. Temporary tables w...

Multi-Table Data Import(MTDI) from one or more supported data sources

Multi-Table Data Import(MTDI) from one or more supported data sources In MicroStrategy Analytics Enterprise Web 10 onewards, users can now simultaneously import two or more tables from one or more supported data sources, this feature is called Multi-Table Data Import (MTDI) which has been renamed as Super Cubes in MSTR 2019 (Does it sound like multisourcing for all the users without admin help?) Currently, all connectors in MicroStrategy Web 10 except " OLAP " and " Search Engine Indices " support Multi-Table Data Import. Users are able to add multiple tables/files when doing data import from single connector, as shown below: Users are also able to combine multiple tables/files from different sources and store them into one single Intelligent Cube, as shown below:

New feature Attribute left outer join effect in MicroStrategy Web

New workaround Attribute left outer join effect in MicroStrategy Web Left outer join for attribute is  unavailable in Developer by changing the VLDB settings in for the attribute and grid.  But, this can also be done with this work around, here are three tables in warehouse. Create three attributes named A, B, C, and after them added in a report in Developer, no data returns, as showed below.   Here is the workaround to achieve the attribute left outer join on MicroStrategy Web.  Follow the steps below. Create three reports named A (with attribute A), A&B (with attribute A and B),A&C (with attribute A and C) Create a dashboard based on the three reports created in last step. In the right corner of the dashboard, change the data source to none.