Select to view content in your preferred language

Compare value of 2 fields in feature report template

150
3
3 weeks ago
RobBlash
Frequent Contributor

I want to compare to fields in a report template but I am not having luck. I want a conditional element like this: ${if field1 != field2} some text ${/}

I've tried a few ways but I can't get the syntax right. None of the below works

${if field1 != field2}

${if field1 != ${field2}}

${if field1 != '"+field2+"'}

Has anyone successfully done this?

 

 

0 Kudos
3 Replies
Neal_t_k
Frequent Contributor

I was able to get below to work using test data.  Is it giving you an error message that you can share?  Is one of the fields in a repeat and the other outside?

${if field1 != field2}

Text here

${/}

Neal_t_k
Frequent Contributor

@RobBlash this also appears to work in tests, however if one of your fields is in a repeat, not sure it would work either:

${#mainLayer | where: "field1 <>'"+ field2+"'"}

text here

${/}

Edit: If one field is in a repeat

field1: main layer

field2: in repeat

${#repeatlayer |where: " field2 <>'"+field1+"'"}

text here

${/}

RobBlash
Frequent Contributor

Fields are not in a repeat. The site would accept the syntax for ${if field1 != field2} (no errors) but it didn’t actually produce the expected result when exporting a sample report. I think the other 2 options threw a syntax error when trying to upload the template. 

Thanks for the reply, in the end I updated the survey to eliminate the duplicate values and put a static “NA” in field 2 that I can easily query for in the report template. 

0 Kudos