Using d2:ceil in a program rule action

Hi everyone

I am trying to evaluate the entire below expression of 4 program variables to either a 0 or 1. My countIfValue functions shown below are successfully generating individual 0’s and 1’s, and by dividing by 4 I am able to limit the possible values to 0, 0.25, 0.5, 0.75 and 1

From here I am trying to apply a d2:ceil function so any value > 0 gives a 1.

(d2:countIfValue( ‘F5.1 ALx1 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.2 ALx2 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.3 ALx3 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.4 ALx4 ruptura de stock’, ‘SIMNAO_NA_NAO’ ))/4.0

When I try to nest this function in d2:ceil ( <> ) however I am only getting blank outputs. I’ve played around with the placement of additional ( ) but have not been able to get this to work.

d2:ceil((d2:countIfValue( ‘F5.1 ALx1 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.2 ALx2 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.3 ALx3 ruptura de stock’, ‘SIMNAO_NA_NAO’ ) + d2:countIfValue( ‘F5.4 ALx4 ruptura de stock’, ‘SIMNAO_NA_NAO’ ))/4.0)

Does anyone have any insight on the d2:ceil function here, or another approach? Essentially if ANY of the 4 program rule variable in the expression == ‘SIMNAO_NA_NAO’ I want to generate a 1, and if NONE of them are I want to generate a 0 for use in a larger formula

1 Like

Hi @Sameen_Babur,

Thanks for raising this issue. Which version of DHIS2 are you on? I have raised this to @dhis2-tracker and they should get back to you whether what you are trying to do it possible or if perhaps another approach is better.

Best regards,
Karoline

Thanks @Karoline! This is on 2.31.6

Hi @Sameen_Babur,

Just a follow-up on this, seems like it might be a bug, are you facing the same problem as in this issue? https://jira.dhis2.org/browse/DHIS2-8775

Best regards,
Karoline

Hi @Karoline, yes that indeed looks like the same issue