Indicator Functions not Working

Hello,

I have been trying to make the if condition work when setting up an indicator in version 2.37.2, but it is not working. Can anyone please help guide how to make it work? Please

Hi @Abumere_Ejakhegbe,
Thank you for your question!

It does say the expression is valid, but what then isn’t working? Would you please explain the point of this condition. Thank you!

Thanks @Gassim for your response.
Yes it shows valid in the statement but when I open the data entry form to check the indicator in the form, it is blank… It does not return the expected answer.

Thanks,

Abumere

How come it says DataItem if( not supported for this type of expression when I try it?

Could you reproduce this in DHIS 2 Demo - Sierra Leone? Thank you!

@Gassim . Thanks for the response. Please check with the latest version. Try using the latest instance in play.dhis2.org. That is were I test this.

Cheers

1 Like

It seems in indicator expression, “if” statement is supported but for program rule expression “if” statement not passing expression validation.

Is there a way or plan of supporting “if” statement in programrule expression?

1 Like

Hi @sohel ,

Essentially the program rule expression is the “if” statement of the program rule.

If [expression] = true, then execute [program rule actions].

You can use logical operators “and” && or “or” || to link subexpressions. If the entire expression then evaluates to true, the program rules execute. See this example in docs for use of && operators. The DHIS2 Tracker Configuration academy also has some good program rule examples, which you can view here.

But maybe you have a more complex use case for program rules which would require nested if statements? If so could you please share more details of what you are thinking?

1 Like

I realize here I was testing the expression by creating a program rule instead of an indicator. For the expression to work, it’d be when creating an indicator and not a program rule.

@Abumere_Ejakhegbe
It might have been because it could be that Analytics Tables export should be run first. :+1:

Thanks for bringing this up! I clarified my mistake above, and you’ve received a response from Brian.

Thanks @brian (: