Hi Neil,
at the first glace I thought that you can optimize your calculation for total2, because r/u * d/n* n = r/u *d. But then I realized that you want use the NUM value of the first context always for the secound NUM in your calculation.
Maybe you can use a combination of udfs to achieve this:
One snipped can be for always returing the last value of an context (execution type: value of contexts)
if (contextValues != null && contextValues.length > 0) {
String value = ResultList.SUPPRESS;
for (int i = 0; i < contextValues.length; i++) {
String str = contextValues[i];
if (str != null && !ResultList.SUPPRESS.equalsIgnoreCase(str)) {
value = str;}}
result.addValue(value);
}
So it would look like this:
If TYPE = X, then Total2 = ((RATE/UNIT) * ( getLastContextValue{setContext higher(DEN/NUM)} )) * NUM
Kind regards
Konrad