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

KB18729: How to set the dynamic aggregation function of a metric using the MicroStrategy Intelligence Server SDK


Community Admin

• Strategy


It is possible to set the dynamic aggregation function of a metric using the MicroStrategy Intelligence Server SDK 9x. The following code demonstrates how to accomplish this:

Dynamic aggregation is the process by which metric results at the base level returned by the database are further aggregated in the Analytical Engine in OLAP Services reports, as shown below:
 

ka04W000000OgD6QAK_0EM440000002Gy0.jpeg

 
Metrics are normally created with the dynamic aggregation function set to 'Default,' meaning that the dynamic aggregation function will be chosen based on the metric's formula. In most cases, this is ok, but sometimes the function should be set explicitly. For more information about the scenarios in which it should be set directly, refer to the following Strategy Knowledge Base technical note:
 
KB15843 (KB5200-75x-2330): What is the function of the ‘Total subtotal function’ and ‘Dynamic aggregation function’ settings in Strategy SQL Generation Engine 8.x?
 
It is possible to set the dynamic aggregation function of a metric using the Strategy Intelligence Server SDK 9x. The following code demonstrates how to accomplish this: 
 


Private Sub cmdGetMetrics_Click()
    Set oObjSource = MySession.Component(DssRoleObjectSource)
    
   'The metric we want to modify
    Dim strM1 As String
    strM1 = "B2A422B8485C2EC21F8ECFB7CFB96D0D"
    Set oMetric1 = oObjSource.FindObject(strM1, DssTypeMetric)    
    
    'Get the subtotal to use for the aggregation function:
    Dim strSub1 As String
    strSub1 = "8D678D5B11D3E4981000E787EC6DE8A4"  'the Total function
    Dim CorrectSubtotal As IDSSMetric
    Set CorrectSubtotal = oObjSource.FindObject(strSub1, DssTypeMetric)
    
    'Get the subtotals collection for our metric
    Set oSubtotals = oMetric1.Subtotals
    
    
    'Iterate through the collection of subtotals until the one named 'Aggregation' is found
    Dim SubtotalIndex As Integer
    
    For SubtotalIndex = 1 To oSubtotals.Count
        Set oSubtotal = oSubtotals.Item(SubtotalIndex)
        
        If oSubtotal.Name = "Aggregation" Then            
            'Change the Aggregation function to the correct Subtotal function 
            Set oSubtotal.Implementation = CorrectSubtotal
        End If
    Next  
    
    'Save the metric back to the MD
    oMetric1.Info.Save    
    
End Sub

 
Code Customization :
WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 21, 2017

Last Updated:

June 21, 2017