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

KB11155: How do metric join types behave when a compound metric and one of its base metrics both appear in the MicroStrategy report template?


Community Admin

• Strategy


When a compound metric is placed in the same template as one of its base metrics, the Metric Join Types don't behave as expected. The following example elaborates on this issue:
 
In the database warehouse, there are two fact tables, Year_Sales_Fact and Item_Sold_Fact. Data in the two tables are shown below:
 
 


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00

 
Item_Sold_Fact
 
 


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00


Parameter NameDefault ValueDescriptionPREFETCHBalance the value based on data sizeWhen set to a non-zero value N, causes all queries in the connection to return N rows at a time rather than the entire result set. Useful for queries against very large tables where it is not practical to retrieve the whole result set at once. You can scroll through the result set, N records at a time.
This option works only with forward-only cursors. It does not work when the option parameter MULTI_STATEMENTS is set. It can be used in combination with the option parameter NO_CACHE.FORWARD_CURSOR0Force the use of Forward-only cursor type. In cases of applications setting the default static/dynamic cursor type and one wants the driver to use noncache result sets, this option ensures the forward-only cursor behavior.NO_CACHE0Do not cache the results locally in the driver, instead read from server (mysql_use_result()). This works only for forward-only cursors. This option is very important in dealing with large tables when you do not want the driver to cache the entire result set.Year_IDItem_Sold2000502001100Year_IDSales1999100.0020002000.00

 
Year_Sales_Fact
 
Two facts and one attribute are defined on the tables:
 

  • Attribute: Year
  • Fact: Item Sold, Sales

Two simple metrics and one compound metric are defined on the facts:
 

  • Item Sold = Sum() {~+}
  • Sales = Sum(Sales) {~+}
  • Unit Sale = (Sales / [Item Sold] )

A simple report is created, with Year, Sales and Unit Sales on the template. When Metric Join Type or Formula Join Type of Unit Sales metric are set to Outer, some notable results are observed.
 
Scenario 1:
In the metric editor, Unit Sales has the relevant join type set as:
 

  • Metric Join Type (Tools > Metric Join Type): Outer
ka04W000000OhT7QAK_0EM440000002Fnd.jpeg
  • Formula Join Type (Tools > Advanced Settings > Formula Join Type): Inner
ka04W000000OhT7QAK_0EM440000002Fnh.jpeg

In the report editor, Metric Join Type (Report Data Options > Calculations > Metric Join Type) for two metrics on the template is set as:
 

  • Sales: Inner
  • Unit Sales: Inner

 

ka04W000000OhT7QAK_0EM440000002FnQ.jpeg

 
When the report is executed, three passes are generated. The first pass calculates Sales; the second pass calculates Item Sold. The third pass combines the results from the first two passes to generate data for Unit Sales and returns the final result to the end user. An inner join between pass 1 and 2 is performed in pass 3. Only Year 2000 data is returned in the grid:
 
 

 

select a11.Year_ID Year_ID,
    a11.Sales WJXBFS1,
    a11.Sales WJXBFS2
into #ZZTRE0015DOSP000
from Year_Sales_Fact a11

select a11.Year_ID Year_ID,
     a11.Item_Sold WJXBFS1
into #ZZTRE0015DOSP001
from Item_Sold_Fact a11

select pa1.Year_ID Year_ID,
    pa1.WJXBFS1 WJXBFS1,
(pa1.WJXBFS2 / pa2.WJXBFS1) WJXBFS2
from #ZZTRE0015DOSP000 pa1 join #ZZTRE0015DOSP001 pa2
on (pa1.Year_ID = pa2.Year_ID)

 
Conclusion:
Although Metric Join Type for Unit Sales is set as Outer at the metric level (in the metric editor), the report level Metric Join Type overwrites it at the metric level and an inner join is performed between two metrics on the template.
 
Scenario 2:
As explained in Scenario 1, Metric Join Type at the report level overwrites those at the metric level. For the following two scenarios, only Metric Join Type at the report level will be discussed:
 
In the metric editor, Unit Sales has the relevant join type set as:
 

  • Formula Join Type: Inner

 
In the report editor, Metric Join Type for two metrics on the template is set as:
 

  • Sales: Inner
  • Unit Sales: Outer

 
Similar to scenario 1, three passes are generated. The first pass calculates Sales; the second pass calculates Item Sold. However, in the third pass, when combining the results from the first two passes to generate data for Unit Sales, a full outer join between pass 1 and 2 is performed. Therefore, as long as a Year has data for either Sales or Item Sold, that Year would appear in the final grid view. With the report level Metric Join Type set as described above, users expect to see only one row of data (Year 2000), but the full outer join performed in calculating the compound metric results in three rows of data returned for the report.
 
 

 

select a11.Year_ID Year_ID,
    a11.Sales WJXBFS1,
    a11.Sales WJXBFS2
into #ZZTRE0015U2SP000
from Year_Sales_Fact a11

select a11.Year_ID Year_ID,
    a11.Item_Sold WJXBFS1
into #ZZTRE0015U2SP001
from Item_Sold_Fact a11

select coalesce(pa1.Year_ID, pa2.Year_ID) Year_ID,
    pa1.WJXBFS1 WJXBFS1,
    (pa1.WJXBFS2 / pa2.WJXBFS1) WJXBFS2
from #ZZTRE0015U2SP000 pa1 full outer join #ZZTRE0015U2SP001 pa2
on (pa1.Year_ID = pa2.Year_ID)

 
Scenario 3:
In the metric editor, Unit Sales has the relevant join type set as:
 

  • Formula Join Type: Outer

 
In the report editor, Metric Join Type for two metrics on the template are set as:
 

  • Sales: Inner
  • Unit Sales: Inner

 
When the report is executed, the same SQL statement is generated as scenario 2 and three rows of data are returned although both metrics are set to perform an inner join at the report level.
 
From the discussion of three different scenarios, it can be concluded:
 

  • Metric Join Type set at the report level overwrites that at the metric level.
     
  • When a compound metric's report-level Metric Join Type or Formula Join Type is set to Outer, there will be a full outer join between the temporary tables that calculate base metrics. If the base metrics are selected to return to the end user in the same pass that calculates the compound metric, since the temporary tables containing data for base metrics are full outer joined, as long as an element has value for either of the base metrics, the row appears in the final grid view. In the example, Year 2001 has value for Item Sold but not for Sales. Although Item Sold is not on the template, since the temporary table containing data for Item Sold is outer-joined to calculate the compound metric, Unit Sales, Year 2001 appears in the final grid view. In summary, when Metric Join type or Formula Join Type for a compound metric is set as Outer, a full outer join would happen between temporary tables for base metrics. Therefore, if a base metric appears in the template, Metric Join Type of the base metrics become irrelevant.
     

Comment

0 comments

Details

Knowledge Article

Published:

May 18, 2017

Last Updated:

May 18, 2017