Use d2:countIfValue for assigning value to DE\TEA

Hi there,

I need an assistance for implementing following scenario:

  1. Briefly there are 2 stages and 3 DE:
    a) Stage B has a DE elements which are gender (dropdown list). The stage is repeatable
    b) Stage A has 2 DE , which represents sum of gender-male and gender-female, which should be able calculated based on the data in stage B and DE in the stage B. Basically I need to display in stage A sum of male and female has been registered in Stage B in the Stage A - DEs respectively.

I found a function: d2:count, d2:countIfValue. Can anyone how I can implement such logic based on these functions? Should I first assign value into programRulevariables or I can directly assign them to the DEs?

Will appreciate any help

Thank you
Regards,
Ulanbek

1 Like

Hi @Ulanbek

If I may ask for further explanation to the scenario as it’s not clear for me:

  1. Why isn’t the gender a Tracked Entity Attribute? Is this DE in Stage B supposed to be the gender of the TEIs?
  2. How is the collection of this information in Stage B (after stage A)?
  3. What does the count have to do with the TEI?

Basically, the common usage is that you would be counting the TEAs (female/male) using a program indicator based on the values entered during enrollment.

Hi @Gassim

In general I have not mentioned any TEA in my post. The idea is following:

Stage A: designed to get a consent to be data collected for the certain period of time. As soon as the consent received we can collect details in the stage B.

Stage B: details of the client. Repeatable stage. It has Unique ID of each client. In the details we collect data: age, sex etc.

Now what I need: I need an auto-count of number of all clients and number of clients by sex in the stage B. Calculated data statistics needs to be assigned to the DE in any stage.
Therefore I was wondering if I can use d2:countIfValue function.

Also there is another question: How can I set relationship between the program stages? I have tried to set up, but didn’t work.

Thank you

Regards,
Ulanbek

Hi Ulanbek,

Based on your description, it sounds like a Tracker program. Your explanation make it even more clear that it should be designed as Tracker Program ( such as enabling relationship between stages… why??) .

Enrollment part can be your person data collection part, such as gender, unique id, name and etc.

Then when you receive a consent, you can hide all DEs in the Stage B and ask if consent is received. If yes, then unhide all DEs for Stage B and they can fill out the rest of the Stage B part.

1 Like

Hi @Daler
Thank you for your proposal. Yes, it is a tracker program, but has many stages inside. In the enrollment it has it’s own attributes(gender, age, key_group etc.) .
I need to count how many men/women consist Stage B and display it by the help of d2:countIfValue. I need a propoer guidance can I achieve it dynamically or not?

Hi @Ulanbek

Why not get the consent during the enrollment? It makes more sense. I still believe that the data that is specific attributes of a tracked entity should be collected as TEA, and the reason is that this will simplify the analytics you’re working on.

To rephrase, you want to count the number of data elements with specific value in a repeatable program stage, but your question is specifically about using d2:countIfValue(). However, I think in this case you will get the values entered in every repeated stage.

Hi @Gassim

The reason is i’m not trying to get a client’s sex\age. I need to collect who the client connected with. And this data must include the sex\age. Therefore I need a stage where the data will be collected and processed.
Yes, I want to understand and use d2:countIfValue() function to assign counted male/female values to the respective field within the current repetitive stages and enrollment.

Is that possible??? @Gassim as long as you are more closer to the developer, I need just straightforward answer how it can be utilised.

Thank you