Public bug reported:

Bug found in 2.22, still present in 2.24 online demo (2.24 rev.23557)
Online demo accessed using Chrome 52.0.2743.116.

There appears to be a bug in the program indicator calculations when:
a sum() custom aggregation is used twice, to enable the calculation of a 
percentage AND
an element of the percentage calculation includes d2:condition.

Note that either of these situations works properly on its own - ie the
numerator and denominator work perfectly when separated into two
different indicators - it is only when combined that the bug occurs.

TO REPRODUCE THIS BUG

In the online demo instance, using the Antenatal Care Visit program:

1. Create a program indicator called TestNumerator, with aggregation type 
'custom' and expression:
sum(d2:condition('#{dBwrot7S420.vANAXwtLwcT}>=10',1,0))

2. Create a program indicator called TestDenominator, with aggregation type 
'custom' and expression:
V{event_count}

3. Create a program indicator called TestPercentage, with aggregation type 
'custom' and expression, which combines these two expressions as a percentage:
sum(d2:condition('#{dBwrot7S420.vANAXwtLwcT}>=10',1,0)) / V{event_count} * 100

4. Create a pivot table based on the Antenatal program, add all three 
indicators to the pivot, and run it:
Numerator and denominator calculate correctly, but percentage returns 2/3 = 0 
(instead of 66.7)

5. Now change the Period from Last 12 months to Last 52 weeks, and re-run:
All indicators now calculate correctly, with percentage correctly showing 0/1 = 
0 and 2/2 = 100.


Note that this is not a bug in the event_count variable, as the same bug 
consistently appears even when V{event_count} is replaced by sum(1) in the 
indicator expressions.

I have a project whose viability depends on being able to correctly
calculate these percentages at higher levels of aggregation (regions
etc), so if confirmed as a bug, I would be hugely grateful if it were
possible to fix this in the current release, rather than in 2.25.

Many thanks, Sam.

** Affects: dhis2
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1612375

Title:
  Program indicators: error in percentage calculations when using
  d2:condition (inconsistent results at different levels of aggregation)

Status in DHIS:
  New

Bug description:
  Bug found in 2.22, still present in 2.24 online demo (2.24 rev.23557)
  Online demo accessed using Chrome 52.0.2743.116.

  There appears to be a bug in the program indicator calculations when:
  a sum() custom aggregation is used twice, to enable the calculation of a 
percentage AND
  an element of the percentage calculation includes d2:condition.

  Note that either of these situations works properly on its own - ie
  the numerator and denominator work perfectly when separated into two
  different indicators - it is only when combined that the bug occurs.

  TO REPRODUCE THIS BUG

  In the online demo instance, using the Antenatal Care Visit program:

  1. Create a program indicator called TestNumerator, with aggregation type 
'custom' and expression:
  sum(d2:condition('#{dBwrot7S420.vANAXwtLwcT}>=10',1,0))

  2. Create a program indicator called TestDenominator, with aggregation type 
'custom' and expression:
  V{event_count}

  3. Create a program indicator called TestPercentage, with aggregation type 
'custom' and expression, which combines these two expressions as a percentage:
  sum(d2:condition('#{dBwrot7S420.vANAXwtLwcT}>=10',1,0)) / V{event_count} * 100

  4. Create a pivot table based on the Antenatal program, add all three 
indicators to the pivot, and run it:
  Numerator and denominator calculate correctly, but percentage returns 2/3 = 0 
(instead of 66.7)

  5. Now change the Period from Last 12 months to Last 52 weeks, and re-run:
  All indicators now calculate correctly, with percentage correctly showing 0/1 
= 0 and 2/2 = 100.

  
  Note that this is not a bug in the event_count variable, as the same bug 
consistently appears even when V{event_count} is replaced by sum(1) in the 
indicator expressions.

  I have a project whose viability depends on being able to correctly
  calculate these percentages at higher levels of aggregation (regions
  etc), so if confirmed as a bug, I would be hugely grateful if it were
  possible to fix this in the current release, rather than in 2.25.

  Many thanks, Sam.

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1612375/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to