Example 1: Apply Time Measure Expression to show difference, difference of percent, and cumulative.
DataItem timeItem = ds.newDataItem();
ds.addBusinessItem(timeItem);
ds.addResultItem(timeItem, Role.COLUMN);
TimeExpressionMeasure timeMeasureExpression = new TimeExpressionMeasure();
timeMeasureExpression.setMeasure(numericExpression); <<== where numericExpression is Sum of Quantity
timeMeasureExpression.setFunction(TimeExpressionMeasure.PERCENTCHANGE_PREVIOUS_PERIOD);
timeItem.setExpression(timeMeasureExpression);
timeItem.setLabel("Percent");
timeItem.setFormat("PERCENT10.2");
DataItem timeItem1 = ds.newDataItem();
ds.addBusinessItem(timeItem1);
ds.addResultItem(timeItem1, Role.COLUMN);
TimeExpressionMeasure timeMeasureExpression1 = new TimeExpressionMeasure();
timeMeasureExpression1.setMeasure(numericExpression); <<== where numericExpression is Sum of Quantity
timeMeasureExpression1.setFunction(TimeExpressionMeasure.DIFFERENCE_PREVIOUS_PERIOD);
timeItem1.setExpression(timeMeasureExpression1);
timeItem.setLabel("Difference");
DataItem timeItem2 = ds.newDataItem();
ds.addBusinessItem(timeItem2);
ds.addResultItem(timeItem2, Role.COLUMN);
TimeExpressionMeasure timeMeasureExpression2 = new TimeExpressionMeasure();
timeMeasureExpression2.setMeasure(numericExpression); <<== where numericExpression is Sum of Quantity
timeMeasureExpression2.setFunction(TimeExpressionMeasure.CUMULATIVE);
timeItem2.setExpression(timeMeasureExpression2);
timeItem.setLabel("Cumulative");
Example 2: Apply Time Measure Expression to show cumulative starting from 2000.
DataItem timeItem = ds.newDataItem();
ds.addBusinessItem(timeItem);
ds.addResultItem(timeItem, Role.COLUMN);
TimeExpressionMeasure timeMeasureExpression = new TimeExpressionMeasure();
timeMeasureExpression.setMeasure(numericExpression); <<== where
numericExpression is Sum of Quantity.
timeMeasureExpression.setPeriod("[Time].[YQMD].[All YQMD].[2000]");
timeMeasureExpression.setFunction(TimeExpressionMeasure.CUMULATIVE);
timeItem.setExpression(timeMeasureExpression);
timeItem.setLabel("Cumulative");