Creating Validation Filters for this Question

Check this box if you need to validate the responses on a page for a question that cannot be handled with the SurveyWriter's built-in functions. This option is used mostly when multiple questions are merged onto a single page and one question's valid answers depend upon its relationship to answers from another question(s) on the same page. 

For example: You create a grid question that lists ten TV shows and asks the respondent to rank their top three favorites. You also want to have an option that reads "I do not watch television." Since a grid question would not allow for a single response question (such as a radio button or check box that reads "I don't watch TV"), you would need to create two questions and merge them to a single page. The first question is the "Ranking Grid" question, and the second question is a single radio button labeled, "I don't watch television."  

Normally, the answers to one question on a page are not validated against the answers to another question on the page. Using the Validation Filters, you could set up a series of rules that would alert the respondent that there is an error if they had answered the "Ranking Grid" question and answered "I don't watch TV".   

One of the complications with using this function is that since you are creating your own rules, you must do error trapping to catch other possible respondent errors such as:   

To create a validation filter for a question, follow the steps below.

  1. Click the Create Validation Filter for this Question box on the Questions Options window.
  2. Click Build Validation Filter. 

    You can enter text directly into the field. Using the Filter Wizard is recommended, however, to eliminate typing errors.
  3. Select the question to use to build the filter.
  4. Select the conditional operator to compare against the response option.

    To handle all the possible validation rules, the filter wizard contains Conditional Operators. Several of these operators are available in the Filter Wizard for Validation Filters only.
Operator Description Examples
= Equals

{Q1-R1 = 1}AND_NOT{Q1-R1 = 6}
Q1-R1 can equal 1 but not 6.

< Less than

{Q1-R1 < 6}AND_NOT{Q1-R1 = 6}
Q1-R1 can equal 1, 2, 3, 4, or 5 but not 6.

> Greater than

{Q1-R1 > 0}AND_NOT{Q1-R1 = 6}
Q1-R1 can equal 1, 2, 3, 4, or 5 but not 6.

! Does not equal

{Q1-R1 < 6}AND{Q1-R1 ! 6}
Q1-R1 can equal 1, 2, 3, 4, or 5 but not 6.

[] Containing

{Q1 [] Coke}
The answer for Q1 must contain the character string or group of letters Coke.

[ Beginning with

{Q1 [ C}
The answer for Q1 must begin with the letter C.

] Ending with

{Q1 [ E}
The answer for Q1 must end with the letter E.

[NB] Not blank

{Q1-R1-Other1 [NB]}AND{Q1-C2-R1 [B]}
The respondent has entered text into the "Other Specify" field in row 1 but has not selected the corresponding option in the second column. 

[B] Blank

{Q1-R1-Other1 [B]}AND{Q1-C2-R1=1}
The respondent has not entered text into the "Other Specify" field in row 1 but has selected the corresponding option in the second column. 

[BC] Branch Code Not applicable to validation filters
[BN] Branch Number Not applicable to validation filters
[L] Length

NOT({Q1 [L] = 5}) 
Requires respondent to answer a question using 5 characters.

[CNT] Count number of responses {Q1 [CNT] > 1}
Respondent must select more than one answer in Q1. 
[SOUNDX1]
[SOUNDX2]
[SOUNDX3]
[SOUNDX4]
Sounds like 

Click Soundx for more information.
{Q1-C1-R1 [SOUNDX2] Federal Express}
The answer for Q1-C1-R1 must be spelled similarly to Federal Express.
[GNB] Grid not blank {Q12 [GNB]}
Checks whether any answers in a grid row, grid column or an entire grid have been answered. If so, a message is displayed.

NOT({Q12 [GNB]})  
Checks whether any answers in a grid row, grid column or an entire grid have been answered. If not, a message is displayed.
[MAX] Maximum answer {Q3-C1[MAX] 3}
Checks for the Maximum answer in a grid row, grid column or an entire grid. 
Checks to make sure no answer entered is greater than 3.  
[MIN] Minimum answer {Q3-C1[MIN] 3}
Checks for the Minimum answer in a grid row, grid column or an entire grid. 
Checks to make sure no answer entered is less than 3.  
[SUM] Sum of column {Q4-C1 [SUM] = |Q1|}  
Indicates that the sum of column 1 in Q4 must equal the answer in Q1.
[RSUM] Sum of row {Q4-R1 [RSUM] = |Q1|}
Indicates that the sum of the answers in Q4-R1 must equal the answer in Q1.
[FRQ] Frequency of Code Value {Q1 [FRQ = 1] > 3}
Indicates that respondent cannot select code 1 in any questions with IDs that contain the letters Q1 more than 3 times. For example, the respondent cannot select code 1 in questions Q1_A, Q1_B, Q1_C, Q1_D, Q1_E more than 3 times. 
[NUM] Is a number {Q1 [NUM]}
Ensures that the respondent enters numeric answer only.
[DEC] Number of allowed decimal places {Q1 [DEC] > 2}
Ensures that the respondent enters numbers with 2 or less decimal places. 
[RN] Rank n Items {Q1 [RN] 2}
Checks whether only n items have been ranked in a ranking question (for example rank your TOP 2 favorites) 
[D] Duplicate answers {Q1 [D]}
Checks whether duplicate answers have been entered in a ranking columns (for example 2 items have been ranked 1st)
[DATE] Check for a valid date {Q1 [DATE]}
Enter date in mm/dd/yyyy format.
[DATECHK] Compare dates entered {Q17a-C1-R1 [DATECHK] > 5/21/2009}
Date entered in row 1 must be later than 5/21/2009

{Q17a-C1-R1 [DATECHK] > SYSTEMDATE}
Date entered in row 1 must be later than the system date.
[EVAL] Evaluate Statement

Usually, the left-hand side of a validation must contain a valid question ID. It cannot contain a number or numeric variable. 

[EVAL] allows you to use and evaluate numbers and numeric variables on the left-hand side of validation filters.  
{[[|9b-C1-R1| + |9b-C2-R1|]] [EVAL] =100}
Sum of these two rows must equal 100.
[RQCNT] Counts number of items selected from column when question is a Row Question {Q1-C1 [RQCNT] > 1}
For the column coded 1::, allow only one answer per column.
C1 represents code value assigned to column, not the column number in order from right to left.
[CQCNT] Counts number of items selected from row when question is a Column Question {Q1-R1 [CQCNT] > 1}
For the row coded 1::, allow only one answer per row.
R1 represents code value assigned to the row, not the row number in order from top to bottom.
  1. Select a response option for the selected question if this is question type that uses codes. 
    If this is numeric or text entry question then type in the value you would like to use in the filter.
  2. Choose whether to add additional parameters to your statement.
  3. Click Save to store the filter.
  4. Enter the message text to display for this filter in the space provided. 

More Validation Filter Examples

These Conditional Operators can be used on a specific grid row, column or entire table. Normally when filtering an item in a grid question you specify either:   

  1. The Grid Row (Q1-R1) for a row question (1st row in question Q1) 
  2. The Grid Column (Q2-C4) for a column question (4th column in question Q2) 
  3. A specific cell (Q3-C1-R2) for other grid type questions (the cell at the intersection of Column 1 and Row 2).   

When using validation filters, you can also specify all answers in a row, column or entire grid. Q1 would check the entire Q1 grid. Q1-C1 would check the entire 1st column of Q1.   

When entering the validation filters you would normally do so on the last questions on the page. In the above example, If the Question ID for ranking your favorite TV shows was Q3 and the "Don't Know" question was Q10a, then the Validation Filters would be built in Q3a.   

Example: Using the above example of rank your three favorite TV shows or select "Don't Know" the following are the series of validation filters and their associated "Message Text" (text displayed if the filter results in TRUE).   

{Q3-C1[D]} Checks for duplicate response in Question 3 Column 1    Message Text: You have a duplicate response in a column.     
{Q3-C1[MAX] 3} Checks to make sure no answer is entered that is greater than 3    Message Text: You have ranked an item with a value higher than 3     
{Q3-C1[MIN]1} Checks to make sure no answer is entered that is less than 1    Message Text: You have ranked an item with a value lower than 1     
{Q3-C1[RN]3}  Checks to make sure 3 items are ranked    Message Text: You must rank 3 items     
{Q3a=1}AND{Q3-C1[GNB]} Checks to see if Q3a = 1 (Don't Know which is assigned a code 1 when the question is built) is answered and also an item in the grid is answered.    Message Text: You cannot select Don't Know and rank a TV show  

Multiple Looping Validations

If you need to repeat the same validation filter for a number of rows, use SurveyWriter's Multiple Looping Validation feature to eliminate repetitive filters.

For example, if you have a question with 15 rows and have to repeat the same validation for each, but need to change only the row number in each validation, you can use the following syntax:

Multiple Looping Validation

Syntax Explanation
* Replaces the row number
[*=15] Indicates number of rows
{*} Replaces row number in validation message

Multiple Looping Validation Filter (works on all 15 rows)

{q5-R* = 6}AND({q5-R* = 1}OR{q8-R* = 2}OR{q8-R* = 3}OR{q8-R* = 4}) [*=15]

Message

In row {*}, please do not select "Don't Know" and another option at the same time.

Original Validation Filter (works on 1 row)

{q5-R1 = 6}AND({q5-R1 = 1}OR{q8-R1 = 2}OR{q8-R1 = 3}OR{q8-R1 = 4})

Message

In row 1, please do not select "Don't Know" and another option at the same time.

Validations in Branching Questions

For validations in branching questions, you must ensure that the validation is correct for each pass the respondent takes through the branching sequence.  To do so, use the following format:

{Q1-Branch|*Branchcode| < 5} 

Q1-Branch indicates the validation is being executed on a question in a branching sequence.

|*Branchcode| pulls in the answer code of the current branch when the validation is performed. So, if the branchcode is 1, SurveyWriter will interpret the filter as:

 {Q1-Branch1 < 5}

By using the Branchcode variable, this ensures the validation is correct for each pass through the branching sequence.