Skip to main content
Counting Loops

Counting the number of times an item is looped

Lorraine avatar
Written by Lorraine
Updated over 8 months ago

You may wish to count how many times an item is looped (i.e the number of times that the “Add Another” button is pressed). Using this you can dynamically update a piece of text depending on whether it is plural or not, for example.

Similar to the previous example for displaying inline looped responses, you will need to create a new attribute that is already in a loop in the template itself. Again, you can add this attribute under a block condition with a phantom attribute (one that will never be answered, with a visibility condition in the questionnaire that will never be satisfied).

You will then create a new operation. This is a Count operation with one argument:

  • Attribute as Array: This is the looped attribute from the questionnaire.

You can then make the conditions in your document dependent on whether an attribute is equal to one (for example, where it should be “Company”), or greater than or equal to two (where it should be “Companies”).

Did this answer your question?