Filtering Selection Variables


Selection variables don't have built-in filtering. Instead, you create a data table containing the available options and then filter that table based on formulas and conditions.

This approach allows you to dynamically display only the options that are relevant to the user's answers.


Step 1: Create a Data Table

Create a table that contains the same options as your existing selection variable.

The table should:

  • Contain all of the same rows (options)
  • Have the same column names as the original selection variable
  • Include the same data for each option

Essentially, you're moving your selection options into a user data table.


Step 2: Change the Selection Source

Open your selection variable and change the Select From setting.

Change:

Options Below

to

User Data

Then select the table you created in Step 1.



Step 3: Create Columns for Your Conditions

Determine what circumstances should control whether an option appears.

For each circumstance:

  1. Create a formula that evaluates whether the condition is true.
  2. Create a matching column in your data table.

For example:

Formula Table Column
isJointLifetimeTF   isNotNiecesNephewsYes  
isMarriedTF   isMarriedYes  
showTrustOptionsTF   showTrustOptionsYes  

Each row should contain a value (such as Yes) indicating whether that option should appear when the condition is met.

Example:

Option isNotNiecesNephewsYes
Option A Yes
Option B Yes
Option C (blank)

Step 4: Apply the Filter

Use the Filter field to determine which rows should be shown.

Example:

class_options|filter: isJointLifetimeTF ? this.isNotNiecesNephewsYes == "Yes" : true

Breaking down the example

  • class_options — the name of the user data table.
  • filter: — tells Knackly to filter the available rows.
  • isJointLifetimeTF — a formula that determines whether filtering should occur.
  • this.isNotNiecesNephewsYes — references the current row in the table.
  • == "Yes" — only returns rows where that column contains Yes.
  • : true — if the formula is false, all rows are returned.

Important: When referencing a column in the current table row, you must prefix the column name with this.  .


Example

Suppose you have four document types.

Document Type isJointLifetime
Trust Yes
Will Yes
Deed
Affidavit

If:

isJointLifetimeTF = true

the filter:

class_options|filter: isJointLifetimeTF ? this.isJointLifetime == "Yes" : true

returns only:

  • Trust
  • Will

If:

isJointLifetimeTF = false

then the expression returns true  , and all four document types are displayed.


Creating More Complex Filters

Filters can combine multiple formulas and conditions using logical operators.

For example, you might only display an option if:

  • the client is married,
  • the trust is joint,
  • and the client does not have nieces or nephews.

As your conditions become more complex, it is often easier to create separate formulas that evaluate each business rule, then combine those formulas in your filter expression. This makes your automation easier to read, maintain, and troubleshoot.


Best Practices

  • Keep your formulas focused on a single business rule.
  • Name your formulas clearly so they describe the condition they evaluate.
  • Use descriptive column names that match the purpose of the formula.
  • Test each condition independently before combining multiple filters.

By storing your options in a user data table and filtering them with formulas, you can create highly dynamic selection variables that display only the options relevant to the current interview.

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