MicroStrategy ONE
Adding a New Rank Metric
This example creates a new rank metric and adds it to the template.
Code sample
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. WebRankMetric rankMetr = rManipul.getNewRankMetric(metric);
8. rankMetr.setAscending(false);
9. rankMetr.setDynamic(true);
10. rInstance = rManipul.addRankMetric(rankMetr);
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 WebRankMetric object by passing the metric as a parameter. Lines 8 and 9 set the attributes for this object. Line 10 adds the rank metric to the template by calling the addRankMetric method on the report manipulation object. The WebRankMetric object is the parameter for this method.