Count: counting characters of a text

Difficulty level: Difficult

What does the functionality do?

Suppose, for a matrix question, you have defined some rows with data to be answered by survey participants. For example, this could be data such as the title of a book, the author and a summary. Now you would like to specify, for example, that the entered length of the summary should not exceed 250 characters. For the implementation of this issue, you can use the count functionality.

Use case and how to set it up?

After you have specified the survey question, you can define the data to be answered in the rows of the matrix question, e.g. Book, Author and Summary. In order to allow participants to enter text for all requested data, the question type for all rows of the matrix question must be set to Text. In addition, only one column should be created for this question.

Initially, the text fields at the various rows in a matrix question are supplied with a fixed length. In order to increase the size of these text fields, you have to include a script in the Hint text. For a description of this procedure, please consult the topic Increase text field length of matrix question incl. one column.

Then you add a value assignment to the survey after the matrix question that allows you to automatically calculate the length of the text (here: summary) keyed in by a participant.

RowVariableData typeIs equal to the following term:
SummaryLengthInteger numbercount(q2_3_1)

The formula count(q2_3_1) is used to add up the number of characters keyed in by a participant in the column of the third row (Summary) of question q2.

In the Execute setting, ensure you select the option Every time the participant passes this point.

If you want to show a participant the total length of the summary, you can include a text block in the survey after the value assignment. In this text block, you can include text like The total length of the entered summary text consists of {{custom.Length}} characters. The placeholder used for the length is always provided with the prefix custom. In order to include a custom placeholder, you can click the link labelled Rich text editor at the top right of the text box. You will then access the RTE window. For more information, please refer to the Rich Text Editor (RTE) article.

Finally, you include a validation element in your survey after the matrix question to verify whether the summary keyed in by a participant in the third row of question q2 does not exceed 250 characters.

If you click on the inserted validation in the survey, you can record the error message and the condition(s) on the right-hand side of the screen. The error message is the message the participant will be presented with if he/she does not comply with the specified condition(s). For example, if the corresponding participant has entered more than 250 characters for the summary, this error message will be displayed. He/She can only proceed with the survey, when less than 250 characters have been used for the summary.

Once you have clicked the Edit conditions button, the Filter window appears on which you can specify the condition(s) under which an error message is shown to a participant. In this example, this is when the length of the summary in row 3 contains more than 250 characters. You could then set this up as follows:

  • Show this validation message
  • if – Custom variable – Length – > 250

After you have completed the setup, you still need to click the green Save changes button.

Updated on June 26, 2023
Was this article helpful?

Related Articles

Need Support?
Please login to your Survalyzer account and use the "Create Support Request" form.
Login to Survalyzer