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

  1. Hi, Thanks for sharing. Very informative and very useful for me.
    PYTHON TRAINING IN HYDERABAD


    ReplyDelete
  2. Hi, Thanks for sharing. Very informative and very useful for me.
    High speed internet Hyderabad

    ReplyDelete
  3. Hi, Thanks for sharing. Very informative and very useful for me.
    open plots in shadnagar

    ReplyDelete
  4. Hi, Thanks for sharing. Very informative and very useful for me.
    HMDA layout near Shadnagar

    ReplyDelete
  5. Hi, Thanks for sharing. Very informative and very useful for me.
    Fiber optic internet Hyderabad

    ReplyDelete
  6. Hi, Thanks for sharing. Very informative and very useful for me.
    Middle Eastern food near Belmont Ave

    ReplyDelete
  7. Hi, Thanks for sharing. Very informative and very useful for me.
    top plots dealers in hyderabad

    ReplyDelete
  8. Hi, Thanks for sharing. Very informative and very useful for me.
    suite with Whirlpool room in kochi

    ReplyDelete

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

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

Microstrategy Caches explained

Microstrategy Caches Improving Response Time: Caching A  cache is a result set that is stored on a system to improve response time in future requests.  With caching, users can retrieve results from Intelligence Server rather than re-executing queries against a database. To delete all object caches for a project 1 In Developer, log into a project. You must log in with a user account that has administrative privileges. 2 From the  Administration  menu, point to  Projects , and then select  Project Configuration . The Project Configuration Editor opens. 3 Expand  Caching , expand  Auxiliary Caches , then select  Objects . To delete all configuration object caches for a server 1 Log in to the project source. 2 From the  Administration  menu in Developer, point to  Server , and then select  Purge Server Object Caches . 4 Click  Purge Now . To purge web cache follow the steps in the link ...

Microstrategy Document Autotext macros:

Autotext  code/macros in  Microstrategy Document/dashboard This is a list of the available auto text macros that the Report Services Document engine recognizes. The following auto text codes allow you to add  document variable information to your document. These auto text codes are automatically replaced by information about the document. Auto text codes for MSTR document/dashboard:  AUTOTEXT DESCRIPTION   {&PAGE}  Display the current page.  {&NPAGES}  Display the total number of pages.  {&DATETIME}  Display the current date and time.  {&USER}  Display the user name that is executing the Report Services Document.  {&DOCUMENT}  Display the document name.  {&DOCUMENTID}  Display the document ID.  {&DESCRIPTION}  Display the document description.  {&PROJECT}  Display the project name.  {&EXECUTIONTIME}  Dis...

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

Custom Subtotal Displays in MicroStrategy

Defining custom subtotal displays in MicroStrategy By default, when users apply subtotals in a report, the name of the subtotal is displayed in the subtotal line items that appear in the report. Users can use custom subtotals to give more control over the characteristics of a subtotal. Custom subtotals allow users to define custom subtotal line items that appear on the reports  U sers can make the subtotal name dynamic by typing special characters in the subtotal name field as listed in the following table. Character Description #A The name of the attribute under which the subtotal appears. #P The name of the attribute to the left of, or above the attribute under which the subtotal appears. #0 All the forms of the parent element. #1 The first form of the parent element reading from left to right or from top to bottom. #2 The second form of the parent element reading from left to right or from top to bottom. #3 The third form of th...

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

Types of filters in Microstrategy

Types of filters in Microstrategy Below are the types of filters: 1. Attribute qualification filter These types of qualifications restrict data related to attributes on the report. a) Attribute form qualification Filters data related to a business attribute’s form(s), such as ID or description. •  For example, the attribute Customer has the forms ID, First Name, Last Name, Address, and Birth Date. An attribute form qualification might filter on the form Last Name, the operator Begins With, and the letter H. The results show a list of customers whose last names start with the letter H. b) Attribute element list qualification Filters data related to a business attribute’s elements, such as New York, Washington, and San Francisco, which are elements of the attribute City. • For example, the attribute Customer has the elements John Smith, Jane Doe, William Hill, and so on. An attribute element list qualification can filter data to display only those customer...