Intermediate variable in DMN

Hi there, I have a scenario where i need to do some rule-based computations in a given sequence.

I wanted to use temporary variable in DMN to hold the value and return the same as part of “last rule”.

I could not find any useful reference, hence submitting a new topic.

Example - i have some rules organised by month (say, Jan, Feb etc). Each rule computes an integer value and will pass on to next rule. The last rule for the month shall have the final result.
I would like to apply “collect” policy so i can see the output at each rule applied.

Thanks in advance.


Hi @hjrc-ct,

from the description, it sounds that you can use a DRG with required decisions to calculate the intermediate value.

Please share your DMN you have so far. This may help to find a proper solution :slight_smile:

Best regards,

Hi @Philipp_Ossler,
Sorry for the delay in responding.
I am attaching sample dmn below. i have a series of calculations (in order) and at each level, the calculation takes into account previous sequence output.

I have “hardcoded” for now values at sequence 1, 2 and 3 respectively.

The last rule outcome is important - however would like to see the intermediate calculations as well. Hence applying collect policy.
calculation_sample.dmn (7.0 KB)
Please advise on a potential way to solve/realise the same.

Sample input:
“variables” : {
“amount” : { “value” : 500.0 },
“inceptionDate” : { “value” : “2020-08-12T00:00:00.000+0530” }

Expected output: (calcCumulative is the output field of interest)
Seq #1 - 100% minus some calc = 0.7750 (77.5%)
Seq #2 - 0.775 minus some calc = 0.6781
Seq #3 - 0.6781 minus some calc = 0.6441

Thank you in advance!


It is hard to give you concrete advice. I don’t understand the example completely.

In general, I suggest splitting the calculation into different parts. For example, calculate the individual values first (calc value 2, calc value 2, calc value 3) and then accumulate them together (value 1, value 1 - value 2, etc.). The accumulation can be done in a decision literal expression, or in a follow-up task.

Thank you @Philipp_Ossler. I am able to apply literal expression and join (chain) it with a decision table. The output generated (by literal expression) is a JSON-string; although not elegant (ex - output containing multiple records), but this will do for now.

Thanks again.