Select to view content in your preferred language

how to create a if statement for a report?

1370
11
Jump to solution
06-05-2023 11:39 AM
JoseBarrios1
Frequent Contributor

Hello everyone

I am having hard time creating a report from survey123. First, I'm trying to just get a sample report using the the "individual record" template but it won't open on Word. I'm getting the attached pic error in word.

My second problem is trying to populate on a report the select_one question that have "other" answer.

The formula works in XLSForm but not on the report. It is just a simple "if statement" that record the entry on <other assessor> field if "otherAssessor" is selected on the select_one questions, otherwise <assessorname> is recorded. 

if(selected(${assessorName},'otherAssessor'),${other_Assessor},${assessorName})

 I just realized that the "if" expressions are different for the report but I can't find any examples or documentation. 

I try this but still won't work: 

${if assessorName == " otherAssessor "}${other_Assessor},${assessorName}${/}

 

error.png

 

Any suggestions?... Thanks

0 Kudos
1 Solution

Accepted Solutions
JoseBarrios1
Frequent Contributor

Thank you Nicole and Doug,

I go it to work! As you indicated, I created a second "if" statement to evaluate the "other" option. Thanks once again for your suggestions! 

Here is the expression for reference!

${if assessorName == "otherAssessor"}${other_Assessor} - ${assessorName}${/}${if assessorName != "otherAssessor"}${assessorName}${/}

Thanks,

JB

View solution in original post

11 Replies
JoseBarrios1
Frequent Contributor

Thanks Doug,

 

I did look at that example, but is not clear to me what was the solution!

0 Kudos
DougBrowning
MVP Esteemed Contributor

Sorry I do not use it much but it almost looks like there is no else.  So if yes do this is all there is.  Prob need 2 if statments to simulate a if.  Just a guess.

Nicole_Ueberschär
Esri Regular Contributor

It looks to me like there are blanks around the expression. " otherAssessor " is not the same as "otherAssessor". And then the reports don't have an else option, they only execute if the expression is true and don't if not. If you need an else then as DougBrowning said, you need another if statement that covers the other options (!="otherAssessor").

Regarding the word issue: did you try this yet? https://support.microsoft.com/en-us/topic/how-to-resolve-the-problem-word-experienced-an-error-tryin...

JoseBarrios1
Frequent Contributor

Thank you Nicole and Doug,

I go it to work! As you indicated, I created a second "if" statement to evaluate the "other" option. Thanks once again for your suggestions! 

Here is the expression for reference!

${if assessorName == "otherAssessor"}${other_Assessor} - ${assessorName}${/}${if assessorName != "otherAssessor"}${assessorName}${/}

Thanks,

JB

JoseBarrios1
Frequent Contributor

I forgot to mention that the issue with word not reading the sample template created by survey123 still not working for me. The MS link suggested by Nicole does not work to solve the issue . I still unable to open ANY sample template (individual record or Combined) created by syrvey123. 

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Sorry to hear that the MS link didn't solve your issue. Do you want to try the attached template? It was only downloaded not further manipulated in word. (It belongs to a quiz in case you wonder about the questions.) 

Did you try a different browser yet? Tech support's favorite advise is clearing the cache 😉  Did you try yet to open the file from a different location?

0 Kudos
JoseBarrios1
Frequent Contributor

Thanks  Nicole,

The file that you attached opened without any problem! I'm not sure what it is going on with the one I created! I did try to download the file with Chrome and Firefox and from different location.

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Really strange. Is it only for this particular survey or is it happening for all surveys? Do you have (by any chance) another subscription where you could try downloading the template?

0 Kudos