Concat: Concatenating two alphanumeric values

Difficulty level: Difficult

What does the functionality do?

A Dutch postal code consists of four digits, a space and two capital letters, e.g. 3524 AS. In order to retrieve the postal codes of survey participants, it is best to include two separate questions in your survey, e.g. a drop-down with all possible 4-digit postal code combinations of a town AND an open question in which the two postal code letters have to be provided. Between the 4 digits and 2 letters of a postal code there should be a space. To correctly display the postal code in, for example, a text block or the raw data, the concat function can be used.

Use case and how to set it up?

First, include a drop-down in the survey asking a participant to select the four digits of his/her postal code (Mandatory question). In the Answer choices, you specify all answer options for the question asked, e.g. postal codes 8200, 8202, 8203, 8211.

Then you add an open question to the survey in which the relevant participant has to enter the two letters of his/her postal code (Mandatory question). Under Text field size, select the Small value and under Response data type, select None.

Subsequently, you create a validation element to ensure that the answer provided by a participant is correct. In the Error message text box, for example, you specify that exactly two letters must be entered. Then, on the Filter window (accessed via the Edit conditions button), you specify the condition(s) under which an error message should be shown to a participant.

Such a condition may look like as follows:

  • Hide this validation message
  • If – Question – q2 – Enter the two letters of your postal code? – matches regex – ^([A-Z]{2})$

If the data entered by a participant (here: two letters) complies with the regular expression, no error message will be displayed. After specifying the regular expression, you still need to click the Save changes button.

Finally, under the validation element, you define a value assignment. You can use this element to include a formula. In the Execute setting, select the option Every time the participant passes this point.

The value assignment formula in the image above can be interpreted as follows: the postal code is composed of the answer option selected by a participant (e.g. 8211) from question q1, a space (indicated in double quotes) AND the two letters specified by a participant (displayed as uppercase letters) from question q2.

When creating the variable, you need to enter a variable name (e.g. Postcode) and select the String (Text) data type. In the box Is equal to the following term: you then define the formula.

If you want to show a participant the postal code he/she entered, you can include a text block in the survey after the value assignment. In this text block, you can include text such as You have entered the following postal code: AND a custom variable placeholder. This placeholder is always allocated the custom prefix, e.g. {{custom.Postcode}}. For a description of the procedure regarding the inclusion of a placeholder in a text box, please consult the Rich Text Editor (RTE) article.

When downloading the raw data, you will notice that the postal codes provided by the participants are displayed in the correct format.

Updated on February 3, 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