How to Sum two or more varibles in Expression of Program Rule?

How to Sum Two or More Variables in the Expression of a Program Rule
Details are below.
I have three variables, and want to add them and check if the total is equal or more than to 100. The expression is
(A{var-1} + A{var-2} + A{var-3}) >= 100

However, I discovered that the result of the expression is the concatenation of the values, not their sum.
for example var-1=23, var-2=20, var-3=10 the result is 232010.

Hi @sami.oracle10g

Would you please describe how your program rule variable is configured, and the whole program rule, expression and action?

Caroline

2 Likes

I create three variables and assigned the values of data elements to them, then I created the program rule expression is (A{var-1} + A{var-2} + A{var-3}) >= 100. If the expression is true the action is display message “the total must not excess over 100”

This issue is discussed here: Addition of calculated Program Rule Variables concatenates values instead of adding - #5 by Gassim

on Jira here: [DHIS2-12029] - Jira

The community post shows my work around. Otherwise you could upgrade to a version of DHIS2 where this bug is fixed.

Best,
Kayla

1 Like

Hi @kstankevitz

Thank you so much for your help, I remember this post and jira, and was about to look it up just now.
Apologies for my late feedback, but I hope this solves your issue @sami.oracle10g

Caroline

1 Like