← Back to team overview

dhis2-users team mailing list archive

Re: Counting Yes Values

 

Hi Maria,

My understanding is that for programs all yes/no (Boolean values) should be converted to 1 or 0 when program indicators are evaluated and analytics tables are generated (see my exchange with Lars below, which was back in 2016).  So if this isn’t happening for an Event Capture or Tracker program, then it’s quite possibly a bug…  But when you say ‘indicators’, do you mean ‘Indicator’ or ‘Program Indicator’?  Are these yes/no data elements in a program or a Data Set?


From: Lars Helge Øverland <lars@xxxxxxxxx>
Date: Wednesday, 2 November 2016 at 12:20

Hi Sam,

Yes, it is expected, and will be continued.

To elaborate: In the trackedentity datavalue table we store boolean values as true | false. We convert this to 0 | 1 when we generate the analytics tables to make it more suited for aggregation (as you point out above).

Re the event capture bug - please report with a bit more context and we will try to fix - it is strange that it shows up as 0.

best regards,

Lars

On Mon, Oct 31, 2016 at 10:51 AM, Sam Johnson <samuel.johnson@xxxxxxxxxx<mailto:samuel.johnson@xxxxxxxxxx>> wrote:

Hi Devs,

I’ve been working on some quite complex program indicators, and before I commit them to production, I would be very grateful if you could confirm how Yes and No are supposed to be handled in program indicator expressions.

I’ve noticed that within the program indicators, they currently resolve as Yes=1, No=0 and non-response=null.  So for example:
· Putting the data element ‘YesNoDE’ itself into an Event Report displays: Yes
· Creating an indicator containing #{YesNoDE} displays: 1
· You can do complex indicators involving the Yes/No data element, eg an index calculation:
        1.2345 + #{YesNoDE_A}*2.3456+#{YesNoDE_B}*0.7654.
· You can even put these complex calculations within a d2:condition, eg to test thresholds:
        d2:condition('1.2345 + #{YesNoDEa}*2.3456+#{YesNoDEb}*0.7654>3.1',1,0)

This is all excellent, as it enables us to do all sorts of powerful calculations/conditions with Yes/No responses interpreted as 1 or 0.  :-)

So my question: is this expected behaviour, and will it remain consistent in future versions of DHIS2?  I’ve noticed, for example, that there are some rendering bugs in Event Capture, where ‘No’ appears as ‘0’ etc – is there any chance that the handling above will be broken when those bugs are fixed, or will I be able to continue to rely on it?




From: Dhis2-users <dhis2-users-bounces+samuel.johnson=qebo.co.uk@xxxxxxxxxxxxxxxxxxx> on behalf of "Guerra-Arias, Maria" <maria.guerra-arias@xxxxxxxx>
Date: Thursday, 27 September 2018 at 10:25
To: DHIS2 Users List <dhis2-users@xxxxxxxxxxxxxxxxxxx>
Subject: [Dhis2-users] Counting Yes Values

Hi all,

I have a series of data elements of value type Yes/No (aggregation type is set to Sum). I want to have an indicator which gives me the total number of Yes values, so I tried defining it as a sum of the data elements, hoping that the Yes(es) would be stored as 1s and the Noes as 0s and I would be able to get a numerical total of Yes(es). Unfortunately this does not work :(

Is there a way to make the indicator that I want?

Many thanks!


--

Maria Guerra-Arias

Global Program Associate

Planned Parenthood Federation of America

Planned Parenthood Global

Cell:     203.747.9268

Skype:  maria.guerra.arias

www.plannedparenthood.org/global <http://www.plannedparenthood.org/global>

www.twitter.com/ppglobe <https://twitter.com/ppglobe>

This email is for the sole use of the intended recipients and contains information belonging to PPFA, which is confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking of any action in reliance on the contents of this email information is strictly prohibited. If you have received this email in error, please immediately notify the sender by reply email and destroy all copies of the original message.

Follow ups

References