Filter a List Using a Computation Variable

If you are using a Computation variable to create a repeated list, you can filter the REPEAT instruction in a Computation variable by using the FILTER COMPUTATION_VAR instruction. (See Filter a List of Answers.)

A filter can be as complicated as it needs to be, but it must result in either true or false. For example, the expression YEARS FROM( Child's Birth Date, TODAY ) produces a number (the age of a person), not a true or false value—it is not a filter. But the expression YEARS FROM( Child's Birth Date, TODAY ) <= 17 can only result in true or false. It can correctly filter all children under the age of 18 from a list.

To filter a REPEAT instruction in a Computation variable

  1. Create a Computation variable that contains your REPEAT instruction. (See Create a REPEAT Instruction Using a Computation Variable.)
  2. Once you have added the REPEAT instruction to the script, drag FILTER COMPUTATION_VAR from the Instruction models list into the Script field. (Place this model on a line of its own, after the REPEAT instruction and any punctuation or sorting instructions but before the RESULT expression.)
  3. Select Computation Variable at the Components list.
  4. Click New Component to open a second Computation Editor.
  5. Assign a name to the computation.
  6. Type the filtering instructions in the Script field, and click OK. HotDocs returns you to the REPEAT computation and the new variable is added to the Components list.
  7. Drag the new variable onto the COMPUTATION_VAR placeholder and complete the REPEAT instruction. An example of a possible script would be:

""

REPEAT Tour Information

ASCEND Tour City

FILTER New York Appearances

RESULT + Tour City + ", " + Tour State + ", " + Tour Venue + "

"

END REPEAT

The New York Appearances filter contains the script, Tour State CONTAINS "new york"

When you use a script to merge a list of answers that have been gathered using a REPEAT, you must first set the computation to a starting value. This value must be a 0 if the result will be a number, or it must be "" if the result will be text.