Any ideas on how to count data elements with the value type text TEXT

I’d like your advice on the DHIS2 analysis.

I’m creating an aggregate tool with questions, including the questions below ones. I created commodities data elements with stock status as option-sets. The issue I encountered was that it was impossible to count the quantity of commodities with understock or other stock status. Do you have any ideas on how to count data elements with the value type text TEXT?

I am assuming you are using are creating a tracker program with different events, each of them will contain the excel presented. If your goal is to have a number of the Commodities without stock, for example, in the above example as follows:
RDT 4 2 Understock
RTUF 4 2 Understock
X 5 4 Overstock
Y 3 3 (empty)

And therefore your expected value would be 2 (I am not sure why you might want that, but let’s assume it). You could create 4 PRV (Program Rule Variable), one per commodity. Create Program Rules to compare the text of your Data Element with “Oversock” and in case of true assign a “1” to the PRV. Then have a last Program Rule which adds that PRV.

A similar example (with booleans in this case) is presented here: Program rule, assign value by summing boolean data elements - #4 by jaime.bosque

1 Like