Is it possible to hide answers in a form?

This article accompanies this sample form. Please read the following and test the sample form. Either save a copy of the sample form in your Google Drive or download as an Excel workbook.

Yes, it is possible to hide answers! You may encounter scenarios where you would like to hide data entries in a form. Perhaps you’re collecting sensitive information which you want to hide immediately to protect that information. Or you might have a self-completion component of your survey, in an otherwise enumerator mediated interview and you wish to prevent enumerators from viewing the answers in the self-completion section. There is a strategy that works well to hide answers while preserving that data, so it appears in exports.

We have dubbed this form programming strategy “no go back”. “No go back” is a setup whereby, when you go backward in a form, any field prepared in this way will no longer be relevant, so will not be visible to the user.

The steps

This is achieved through the following steps:

  1. Place a field you want to disappear inside a group. Let’s call this field “sensitive”.
  2. Place a calculate_here field immediately after the group and give it the expression: “once(${sensitive})”. Let’s call this calculate_here field, “sensitive_response”.
  3. Give the group in which “sensitive” is located the following relevance expression: “string-length(${sensitive_response})=0”.

Discussion of the method

So, what is happening here in this setup? When you reach “sensitive” in your form design, it is relevant because the enclosing group is relevant (relevance applied to a group applies to all fields within). The enclosing group is relevant because the length of the value stored in “sensitive_response” is equal to 0 (it is empty). However, when you enter a value into “sensitive” and move forward in the form, the enclosing group becomes no longer relevant, so won’t be visible to the user if they go back.

A calculate_here field is a location sensitive field. The expression that you place inside a calculate_here field will evaluate as you pass that point in the form. This is in contrast to a calculate field which can re-evaluate at different points while completing a form. So, at the same time as when the enclosing group becomes no longer relevant, “sensitive_response” captures the value entered into “sensitive”. Enclosing an expression inside the function, once(), means that if you move past this point in the form again, the calculate_here field won’t change. This is important because once a field that has a value is no longer relevant, that value will not appear in exports. This is why it is critical in this form design strategy that you use the calculate_here field with once() to capture and store the value.

This strategy is demonstrated in the sample form also linked above. Study it in the context of the above explanation. The sample form includes a confirmatory question, asking whether the answer in “sensitive” is correct because it is not possible to revise “sensitive” once you move forward. The confirmatory question is not essential to this strategy but keep this limitation in mind.

Expansion of the strategy

This approach can be expanded upon to work with more than one sensitive field, including groups of fields displayed together on the same screen using the “field-list” appearance option for an enclosing group. Take care when preparing sections like this and always test your form design, including viewing exported data, to be sure that “sensitive_response” (and similarly prepared fields) have indeed stored the intended values.

A warning

Test your implementation of this programming method very carefully (including submitting data and exporting it). Every detail outline in the sample form is important. Fields which are not relevant don't store values that get passed into submitted data. “sensitive_response” must store the value inside “sensitive” at precisely the same time that “sensitive” becomes not relevant, or else that value will be lost.

Read about calculate_here and other fields in the core concepts product documentation. Also, read about string-length(), once() and other functions in the topic on using expressions in your forms.

Do you have thoughts on this support article? We'd love to hear them! Feel free to fill out this feedback form.


Article is closed for comments.