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

KB36838: How to obtain precise decimal values of divisions of two integers defined in a compound metric in MicroStrategy Engine


Community Admin

• Strategy


This article notes an issue with precision for integer division

By default, the result of divisions of two integers defined in a compound metric is also an integer. Even if the metric is formatted to have decimal places, the values of the decimal is 0.
 
Follow the steps to obtain the precise decimal values

  • Suppose there are two facts, F1 and F2, which are mapped to two integer columns in a fact table
     
  • Create metrics M1=Sum(F1) and M2=Sum(F2) based on the above two facts. M1 is shown below as an example:

ka04W000000OhUcQAK_0EM440000002Dg4.jpeg
  • Create a compound metric M3=M1/M2, as shown below:

ka04W000000OhUcQAK_0EM440000002Dg0.jpeg
  • Format metrics M1, M2 and M3 to have 2 decimal places, as shown below:

ka04W000000OhUcQAK_0EM440000002Dfy.jpeg
  • Create a report with the above three metrics in the grid and execute it
     
  • Observe the result: all of the three metrics' decimal places are shown as ".00". The values are correct for M1 and M2 because they are integers which do not have decimal values. But for M3, the value is not expected if the division of M1/M2 is not an integer. In this case, 151.00/344.00=0.44

ka04W000000OhUcQAK_0EM440000002Dfu.jpeg
  • In order for M3 to have the precise value in the decimal places, one possible workaround is to define a compound metric M3=(M1x1.0)/M2, as shown below:

ka04W000000OhUcQAK_0EM440000002Dg2.jpeg
  • Observe the report result again: metric M3 is showing the expected decimal value.

ka04W000000OhUcQAK_0EM440000002Dfw.jpeg

 


Comment

0 comments

Details

Knowledge Article

Published:

May 17, 2017

Last Updated:

May 17, 2017