MicroStrategy ONE
Adding a New Transformation Metric
This example creates a new transformation metric and adds it to the template.
Code sample
This code sample assumes the presence of a transformation object woi. This transformation object is of type EnumDSSXMLObjectTypes.DssXmlTypeRole and subtype EnumDSSXMLObjectSubTypes.DssXmlSubTypeRoleTransformation. For details, refer to EnumDSSXMLObjectTypes and EnumDSSXMLObjectSubTypes.
1. WebReportInstance rInstance = rSource.getNewInstance(reportID);
2. WebReportManipulation rManipul = rInstance.getReportManipulator();
3. WebTemplate template = rInstance.getTemplate();
4. WebTemplateMetrics wtms = template.getTemplateMetrics();
5. WebTemplateMetric wtm = wtms.get(0);
6. WebMetric metric = wtm.getMetric();
7. WebTransformationMetric transformMetric = rManipul.getNewTransformationMetric(metric, woi);
8. transformMetric.setFormulaType(EnumDSSXMLMetricFormulaType.DssXmlMetricFormulaDifference);
9. rInstance = rManipul.addTransformationMetric(transformMetric);
Explanation
Lines 1 and 2 create and retrieve the WebReportManipulation object required to add the derived metric. Lines 3-6 get the metric from the template. Line 7 creates a WebTransformationMetric object by passing the metric and the WebObjectInfo object that represents the transformation object as parameters. Line 8 sets the attributes for this object. Line 9 adds the transformation metric to the template by calling the addTransformationMetric method on the report manipulation object. The WebTransformationMetric object is the parameter for this method.