Hi! I've got a working report template, but I have some text responses that I only want to appear when relevant. My issue is the input is a number and so when it's empty, the report still evaluates it as a zero, but zero is also a valid input and I need a different message for a null/empty field vs >=0.
${if NitrateResult == "" || NitrateResult == null} evaluates as true in the report even if the user actually entered in zero. And the reverse, if the field is empty: ${if NitrateResult >=0 && NitrateResult <0.5} evaluates as true even though the user didn't enter in 0.
I'm wondering how to tackle this so both messages don't appear when the field is empty or zero which is what is happening now:
${if NitrateResult == "" || NitrateResult == null}Not Reported ${/}${if NitrateResult >=0 && NitrateResult <0.5}Your nitrate results were under detection. This means that your water is below the Health Risk Limit of 10 mg/L (milligrams per liter) for nitrate. ${/}
I've tried ${if NitrateResult != "" && NitrateResult != null && NitrateResult >=0 && NitrateResult <0.5}, but Survey123 just errors and fails to fetch the report:
${if NitrateResult == "" || NitrateResult == null}Not Reported ${/}${if NitrateResult != "" && NitrateResult != null && NitrateResult >=0 && NitrateResult <0.5}Your nitrate results were under detection. This means that your water is below the Health Risk Limit of 10 mg/L (milligrams per liter) for nitrate. ${/}
This prevents both messages from appearing when the user enters 0 or nothing, but the second message doesn't appear when the user enters zero, which is what I'm after:
${if NitrateResult == "" || NitrateResult == null}Not Reported ${/}${if NitrateResult >0 && NitrateResult <0.5}Your nitrate results were under detection. This means that your water is below the Health Risk Limit of 10 mg/L (milligrams per liter) for nitrate. ${/}
Have you considered adding a calculate to your Survey123 Excel to give you a non-zero output. Basically, add the logic you are doing in the Feature Report could be added to S123 instead. That would handle 0 and null.
What would that look like? Like if the user inputs 0 have the survey change it to -1 or something?
I'd really like the keep zero as a valid response in the database and it not be seen as null in the report.
Honestly, it could look like whatever you'd like.
And I agree. The laboratory result should remain as-is. You would have separate field that would be used exclusively for the Feature Report formatting. For example, you could so something like:
Result | Outcome |
empty | A |
0 | B |
>=0 && <0.5 | C |
Then in your Feature Report, you would use something like ${if calculate_field="A"}Not Reported.${/}
Just one note if you try this, use string-length() to test for an empty field. A string-length of 0 means the field is empty.
@Teresa_Blader This is the same concept as I explained previous, but instead of a paragraph, you are just using a placeholder for your text. Then applying the conditions again in the report to put in your text..
Oh gotcha!
That might be the best way to tackle it, kind of similar to the other idea from @Neal_t_k , but just not including the whole paragraph of text. Or maybe at a minimum I have a letter designation if it is 0 in the survey so I don't have to notate all the ranges for all the questions.
Granted the idea of adding a whole new field for all 20 of my lab result fields just to store a code is kinda bleh haha