EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

MicroStrategy Announces Integration with Microsoft® R Client


Kyle Petrillo

Technical Support Intern • Strategy


Collaboration Brings Advanced, Intelligent Analytics and Machine Learning Capabilities to MicroStrategy Users

Requirements

The goal is to build a highly formatted pixel perfect document from a dataset that has data on multiple levels of a hierarchy. You want to visualize:

  • Dynamics of a single metric per Day
  • Data is displayed on multiple levels of Product hierarchy and each level has separate formatting style. There should be no indentation of levels.
  • Subtotals : This Year, Last Year, Difference, Difference %
  • The document must be prompted, so users will be able to change analyzed time period. Important (and tricky) requirement is that users can pick different number of days.

Screenshot of the final document – red numbers mark requirements that are particularly tricky and require special approaches or work arounds

ka04W000000OgB0QAK_0EM4W000004bHuO.jpeg

 

Test Environment

This example has been built in Strategy Tutorial project (MSTR version 2021 U5) in which I’ve built the following objects (underlined objects exist in Tutorial already, the others were created by me):

  • Financial Document – my main document that contains two datasets: Financial Dataset, Cross Join Report
  • Prompt (Elements of Day)
  • Count Days object metric
  • Financial Dataset report contains 4 attributes (Category, Subcategory, Item, Day), two object metrics (Revenue, Last Year’s Revenue), one derived metric (Revenue Der) and one prompt (Elements of Day)
  • Cross Join Cube contains 4 attributes (Category, Subcategory, Item, Day) and one metric (Count Days)
  • Cross Join Report was created on top of Cross Join Cube. Cross Join Report contains the same objects as Cross Join Cube + one additional prompt (Elements of Day)
  • Four custom subtotals: Rev TY, Rev LY, Rev Diff, Rev Diff %


 

First Challenge missing columns

When you run Financial Dataset report you will notice that there are data gaps – not all the Items were sold on all the days. You can suspect those gaps would become a problem in the document preventing you from getting a clean, consistent structure.

ka04W000000OgB0QAK_0EM4W000004bHs8.png

 
Create your document, position grids on different grouping sections and you can see that you were right with the suspicions. Days with no sale are removed from the grid. Grids on different levels have different number of columns and it doesn’t look clean. For example, there was no sale of Cameras Items on 2019-03-02.

ka04W000000OgB0QAK_0EM4W000004bHs9.png
ka04W000000OgB0QAK_0EM4W000004bHsA.png

The way to resolve it is to create a second dataset that would contain a cross join of all attributes from your document Group by (in my case Category and Subcategory) + the lowest level from Detail Section (in my case Item) + Day attribute. Depending on your data structure this dataset can be very large (many thousands of rows). It is advised to create a cube to guarantee sufficient performance.

ka04W000000OgB0QAK_0EM4W000004bHsG.png

You need to create and add to the cube a new metric that would show a value for every cross section, for example Count Days. Here is it’s simple formula:

ka04W000000OgB0QAK_0EM4W000004bHsH.png
ka04W000000OgB0QAK_0EM4W000004bHsI.png

After publishing the cube you can test that, indeed, there is a value for every cross section of attributes. The actual value doesn’t really matter – only the presence of value is important.

ka04W000000OgB0QAK_0EM4W000004bHsJ.png

My final “Financial Document” will be prompted (Select Days). I want my cross join dataset to be prompted with the same prompt object, because:

  • The same prompt object means the user will be asked only once to select days.
  • Prompt will filter my huge Cross Join Cube, so I will not load the whole big cube with all unnecessary cross sections.

Unfortunately, prompts cannot be used in cube definition. In order to solve that I’ve built a “Cross Join Report” on top of “Cross Join Cube”. The report contains all the attributes and metrics from the cube + the same prompt that I also use in my “Financial Document”. This Community post contains information about adding prompts to reports based on cubes (it is not obvious how it’s done!): https://community.strategy.com/article/KB44364-How-to-build-a-prompt-in-a-report-created-from-an?language=en_US
I can add the new “Cross Join Report” to my “Financial document”. They are using the same attributes, so no attribute mapping is necessary.

ka04W000000OgB0QAK_0EM4W000004bHsK.png

I need to create a new derived metric by combining Revenue with Count Days. This will force analytics engine to fill in gaps in data and that would guarantee equal number of columns on each level. A simple formula like Revenue + (Count Days – Count Days) will work. As you can see, this formula returns Revenue value. I use function ZeroToNull() to get rid of zeros in my grids.

ka04W000000OgB0QAK_0EM4W000004bHsL.png

For my document to work properly I need to add all three metrics to all the grids (it’s important for metrics calculation and subtotals), but in fact I don’t really want to display values of Revenue Der and Last Year’s Revenue. I want to hide them.

ka04W000000OgB0QAK_0EM4W000004bHsM.png

The solution is to resize the width of unwanted metrics to 0

ka04W000000OgB0QAK_0EM4W000004bHsN.png
ka04W000000OgB0QAK_0EM4W000004bHsO.png

 
 

Problem 2

The other problem is caused by empty grids in my document. The usage of Count Days metric (from cross join dataset) forces Strategy to display an empty grid even if there is no data for Item-Day combination.

ka04W000000OgB0QAK_0EM4W000004bHsP.png

There are three settings that must be changed to solve it
For each section: In document properties check „Hide null/zero toggle behavior”

ka04W000000OgB0QAK_0EM4W000004bHsQ.png

For each grid: make sure Height is set to “Fit to contents”

ka04W000000OgB0QAK_0EM4W000004bHsR.png

On Project level: Change project level setting “No data returned” to “Hide document grid”.

ka04W000000OgB0QAK_0EM4W000004bHsS.png

Intelligence Server restart might be required at this point. After that the empty grid will disappear and the sections will collapse if empty.
All those efforts were needed to achieve our requirement to display an empty column in case there were no sale recorded in particular day.

ka04W000000OgB0QAK_0EM4W000004bHsT.png

 

Problem 3 – Subtotals creation and sorting

The requirement was to display 4 subtotals on the right side of the grid in this particular order with particular formatting:

  • total [$]
  • total LY  [$]
  • total - total LY  [$]
  • (total - total LY) / total [%]

We can achieve that by creating custom subtotal objects and assigning them to metric Revenue. I created those subtotals with the following formulas:

  • Sum(x) {@}
  • Sum(((x - x) + [Last Year's Revenue])) {@}
  • Sum((x - [Last Year's Revenue])) {@}
  • ((Sum(x) {@}  - Sum([Last Year's Revenue]) {@} ) / Sum(x) {@} )
ka04W000000OgB0QAK_0EM4W000004bHsU.png

You need to create subtotals as objects first and then add them to grid report in specific order starting from the subtotal that will be placed leftmost. If you confuse the order of adding subtotals you will need to remove all subtotals and add them again. Also, pay attention to the names of subtotals because it is almost impossible to change them after they are added to the grid. Set the proper subtotal names right in the beginning to avoid deleting metrics, subtotals or even the whole grids from your document.

ka04W000000OgB0QAK_0EM4W000004bHsV.png

Creating custom subtotal objects: https://community.strategy.com/article/KB9688-How-to-create-a-custom-subtotal-using-a-custom-expression?language=en_US
Sorting subtotals: https://community.strategy.com/article/KB8547-How-to-change-the-order-of-different-subtotals-in-a?language=en_US
 

Problem 4 – subtotal data format

The next challenge is related to different data types in subtotals. First three subtotals are of numeric data type, the last one is percentage. Custom subtotals in one grid are formatted together as “Subtotal Values” and must have the same data type format. So, either all currency or all percentage.

ka04W000000OgB0QAK_0EM4W000004bHsW.png

Solution: have two almost identical grids; one hidden underneath the other. The difference is that the top grid contains 3 subtotals only (all numeric format) and the bottom grid contains all 4 subtotals (all % format). Since the top grid is more narrow we can see the fourth subtotal of the bottom grid on the right.

ka04W000000OgB0QAK_0EM4W000004bHsX.png
ka04W000000OgB0QAK_0EM4W000004bHsY.png

Only in the document structure you will be able to see that there are two grids in Category section. To the end user it will look like one grid.

ka04W000000OgB0QAK_0EM4W000004bHsZ.png

 

Problem 5 – final formatting

Everyone with experience in building Report Services Documents knows that in order to achieve great results and beautiful end documents you need to spend substantial amounts of time on fine tuning. The best approach in this case is to start with formatting the first grid on Category level with 4 subtotals (% data format).

  • Set custom column width
  • Change font format
  • Change background and borders of various sections of the grid
  • Hide some grid components

Most of those settings can be changed in Web interface, but some are only exposed in Developer.
After the first grid is ready, copy the grid, remove the fourth subtotal, change subtotal format to numeric, place the new grid exactly on top of the first grid.
Copy both grids to Subcategory section and apply formatting changes to font color and size
Copy both grids to Item section and apply formatting changes to font color and size
 


Comment

0 comments

Details

Knowledge Article

Published:

June 8, 2017

Last Updated:

June 8, 2017