Working with multiple IF macros

Before we dive into these examples, you may want to revisit how to create basic conditional logic with IF macros. We’ve previously covered this in Use IF macros to adapt templates based on user selection. That article shows the fundamentals of writing IF conditions and using them to tailor your output.

In this article, you'll learn how to stack IFs macros to evaluate multiple conditions.

We’ll build on that foundation with two real-world scenarios:

  1. A PHQ-9 template, where multiple IFs appear but only one condition can be true, because the score ranges are mutually exclusive - multiple IFs in sequence.
  2. A hospice template, where several IFs can be true at once, and each one may contribute output, requiring careful handling of line breaks to keep the final text clean with multiple interdependent IFs.

Multiple IFs in sequence

In this example, multiple IF statements are used, but only one IF will ever be executed and produce output.

We are evaluating the total variable with multiple IFs.

We have set the range so that only one IF is true, thus displaying the appropriate text.

Multiple IFs in sequence. Once one is evaluated to true based on the value of the total variable

Using multiple IFs to calculate the score

  • Multiple IF statements are used, but only one will run
  • Each IF checks whether the calculated PHQ-9 score falls within a specific range and, if so, outputs the corresponding text.
  • Each score range must be mutually exclusive
  • Put one statement per line to avoid displaying extra spaces
  • Even though several IFs are present, only one condition will match and produce output

Multiple inter-dependent IFs

In this example, the IF statements behave differently from those in the PHQ-9 template. Multiple options may be selected, and each option is evaluated independently.


Several IF statements may produce output, while others may not. It’s essential to ensure that IF statements that are not triggered do not insert additional empty lines.

We have added an extra line before the {#endif#} statement to ensure that when an IF is true it adds a line break.

To prevent extra blank lines from appearing in the final output when some sections are skipped, make sure that each if statement is attached to the previous one without extra new lines.

Each IF section contains it's own trailing line break

Each IF statement is evaluated independently, and each one may or may not produce output depending on whether its condition is met.

How to ensure the proper output is generated

When concatenating the output from multiple IF statements, spacing is essential to avoid unwanted blank lines.  A common approach is to:

  • Include one empty line after each IF output
  • Ensure that the {#if#}  statement is written in the line directly following the {#endif#} without any extra new line characters.

How to install a glossary

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us