Select to view content in your preferred language

Omit Null Responses in Summary Report

116
4
Jump to solution
01-16-2025 05:31 AM
jzibbell_boise
Regular Contributor

We created a Survey123 for employee evaluations. Reviewers could optionally leave a comment in their evaluation. Below is the syntax I'm using to list all of the comments provided for an individual, but I'd like to omit responses that did not leave a comment. I have tried the ${if comments} {/} syntax but I'm not placing it correctly because Survey123 will complain that comments isn't in the parsing scope, even though it is. 

 

Comments:

${#Boise_Fire_360_Evaluations_1 | where: "personnel = 'name' AND reportingYear = '2024' !important”| orderByFields: "objectid asc"}${comments}

__________________________________________________

${/}

OR THIS:

${if Comments #Boise_Fire_360_Evaluations_1 | where: "personnel = 'NAME' AND reportingYear = '2024' !important”| orderByFields: "objectid asc"}${comments}

__________________________________________________

${/if}

0 Kudos
1 Solution

Accepted Solutions
abureaux
MVP Frequent Contributor

Try something like ${#Boise_Fire_360_Evaluations_1 | where: "personnel = 'name' AND reportingYear = '2024' !important”| orderByFields: "objectid asc"}${if comments}${/}

If used on its own should show the element only if it has a response. Alternativley, you can use it like ${if comments}${comments}${/}. Result should be the same though.

View solution in original post

0 Kudos
4 Replies
abureaux
MVP Frequent Contributor

Try something like ${#Boise_Fire_360_Evaluations_1 | where: "personnel = 'name' AND reportingYear = '2024' !important”| orderByFields: "objectid asc"}${if comments}${/}

If used on its own should show the element only if it has a response. Alternativley, you can use it like ${if comments}${comments}${/}. Result should be the same though.

0 Kudos
jzibbell_boise
Regular Contributor

Thanks @abureaux, that was it!

0 Kudos
TylerGraham2
Frequent Contributor

I've been fighting the ${if} statement a lot these past couple days, it seems much more finicky than in the past and I was having the same issues you were with the parsing scope. If I was opening the ${if} statement starting in one style (like Heading 1 in word) and closing it in a different style (e.g. Body) I would consistently get the parsing error. I've attached an example of how I laid out an if statement that shows or hides a repeat table based on if any of 3 fields has an attribute with different document styling.  

FYI, I was also having problems with the syntax of the ${if} statements:

${if field1 | selected:"yes" || field2 | selected:"yes"}...${/}

Would give me some weird parsing errors where parts of the field name were truncated, like it would be looking for "eld1" instead of "field1" in the error message.  The issue there seems to be with having 2 or more "selected:" expressions in the if statement. 

I changed it to:

${if field1 == "yes" || field2 == "yes"}...${/}

and that would work without giving me a parsing error. I also had an if statement that used 1 selected expression and a different expression and that had no problems running.

${if field1 | selected:"no" || field == null}...${/} worked just fine.  

 

For yours, I'd start with just the bare bones and everything on a new line in the doc (see below), then add any additional fields and where clauses and test.  

${if Comments}

${#Boise_Fire_360_Evaluations_1}

${eval_field1} <-I'm just pretending this is a field in your Evaluation table, use one of your actual fields to bring in data.

${/}

${/}

0 Kudos
jzibbell_boise
Regular Contributor

Appreciate the response @TylerGraham2  I couldn't get it to work with the ${if comments was outside of the ${#

0 Kudos