Create variable in which single select question code is converted to the equivalent string value

Dear all,

I’d like to add a variable on the cover page of my questionnaire to show the village location of the interview on the enumerator dashboard. The village question is a single select question and I would like the dashboard to show the associated string value.

E.g.
Q1 village
1 Concepcion
2 Carmen
etc.

I think I have to create a string variable on the cover, but not sure what exactly should be in the expression of the variable (named c_vil).

village.ToString()

clearly only gives the code as a string value.

I searched the forum for similar questions and found some (eg Enabling condition based on multi select answer order or Categorical Question String Value). From that I think I have to write out the full conversion for all answer options in the expression, but not knowing C#, I haven’t been able to figure out the precise way to write it in my expression.

For addtional info if helpful: I do not have a problem with translation, as the village names are identical in all translations. I do not want to place the village question directly on the cover page (see earlier post Additional interview information on tablet's Completed Screen in 'census' mode).

I’d appreciate any help anyone could provide!

Cheers,

Sebastiaan

After some more trying, I managed what I wanted. Just wanted to share this in case anyone else wanted to do something similar:

In the expression of the string variable I entered:

village==1 ? "Concepcion":
village==2 ? "Carmen" : "Missing"

Where “village” is the name of my variable. In the example here, I assumed there were only 2 villages, with “Missing” shown if no village has been selected by the enumerator.

I also wanted to add a variable on the Cover showing the starting time of the interview (it includes a time stamp at the start). Creating a Date/Time variable and entering the time stamp variable name (“tim_start”) in the expression only showed the date and not the time, so I created a String variable and entered the following expression:

tim_start.ToString()

This seems to work.

Cheers,

Sebastiaan

Thanks for posting. Note that questionnaires with this approach will have challenges in translation as the text that you are substituting is language-neutral.