Hi everyone,
Does DHIS2 by default support OR logic in Event Reports?
Thanks
Hi everyone,
Does DHIS2 by default support OR logic in Event Reports?
Thanks
Hi @dmbantu
Would you please explain further what do you mean? If you can share an example of what you have in mind please…
Thanks!
Hi, dmbantu
Yes, DHIS2 supports OR logic in Event reports, but only in specific scenarios or with a workaround.
In this instance, you can use OR logic when filtering for multiple values within the exact same data element (e.g., Vaccine equals ‘BCG’ OR ‘OPV’).
This can be done via the following steps:
In the Event Reports or Event Visualizer app, add a filter for the data element you need.
Choose the in operator (or select multiple checkboxes/options if it’s an Option Set).
Enter or select all the desired values (e.g., ‘BCG’, ‘OPV’).
The DHIS2 engine interprets all values entered in the in operator as an OR condition, matching any of the listed values.
If you need true OR logic across two different data elements (e.g., DE_A = ‘X’ OR DE_B = ‘Y’), the standard Event Reports UI won’t work, because it ANDs every separate filter line together.
However, here is a recommended workaround that may work for you. Try this to implement custom logic directly within DHIS2 for reuse in reports, dashboards, and line lists.
Create an Indicator: Go to Maintenance > Program indicators.
Define the OR Logic: Create an expression that tests both conditions and outputs a ‘1’ if either is true (OR), and ‘0’ otherwise.
Conceptual Example: d2:condition( “(#{DE_A} = ‘X’) || (#{DE_B} = ‘Y’)”, 1, 0 )
Example Scenario: For events where fever = ‘Yes’ OR cough = ‘Yes’, the expression would be: d2:condition(“(#{fever} = ‘Yes’) || (#{cough} = ‘Yes’)”, 1, 0).
Apply as Filter: Use the new Program Indicator in your Event Report or Line Listing, filtering for cases where the indicator equals 1.
Please always test your program indicator expressions in a staging instance or with a small dataset . Syntax and supported functions vary slightly by DHIS2 version.
Hi @e4eDHIS2,
For our scenario, I think “Option 2 seems like the best choice.” because we have two data elements from two different stages. We want to view data if S1_DE = yes or S2_DE = yes.
Thanks
Maybe try ‘one of’ instead? You’re welcome to share more details about your use-case so we can have a complete overview for a solution.
Thanks!
Hi @Gassim,
Let’s consider this example scenario
Let’s say we have:
Data Element: “Fever” (Yes/No)
Program Stages:
Stage 1: Initial Consultation
Stage 2: Follow-up Visit
Both stages use the same data element “Fever”.
How Event Reports/line listing Treat (same DE, different stages). Are Multiple filters in the same report combined with AND or OR?
Thanks.
Sorry for the delayed response.
I found this table in the docs and I think it clarifies the difference:
If you are using multiple conditions, the logic will be AND, not OR.
I think you’d basically need to create a program indicator as @e4eDHIS2 suggested above.