Select to view content in your preferred language

Adding repeat query to if statement

74
1
yesterday
TL2
by
Frequent Contributor

I have an if statement below that produces a "Yes".

${if (1>=0)} Yes${/}

 

I have a query statement below that produces a "1". 

${Inspection | where:"status='Deficient'" | stats:"count, q_2"}

 

 I am unable to place the query inside the if statement without getting errors - mostly unclosed or unopened.

How do I combine the two?

 

 

0 Kudos
1 Reply
VenkataKondepati
Regular Contributor

In Survey123 report templates you can’t nest a where | stats query inside an if statement because queries are evaluated separately, which causes parsing errors. Instead, run the query first, assign the result to a variable, and then use that variable in the if condition, like this:

${Inspection | where:"status='Deficient'" | stats:"count" | assign:"defCount"}
${if defCount > 0}Yes${/}


0 Kudos