Can I use substr function in "select one" using name not label?


I have “Select One” type question. From these Question I am selecting
“Division” + “Location” and using substr(${Q1},0,3) , I am creating unique ID:

Here I can use substr() function using label of the “select one” question.

But this label has “name” in “choice” tab.
Is this possible I can select name when I choosing label?

May be I am not explaining properly.
Shall I share my xlsx form?


Asif R Joy

Maybe this workaround shared below should be able to show you how you should be able to use substr to extract the information from a select-one question type:

In the survey tab of your XLSForm:

Image 1

In the choices tab of your XLSForm:

Image 1.0

Data entry screen as seen in Enketo:

Reference XLSForm:

substr from Jr choice name.xlsx (11.4 KB)

1 Like

Hello @asif_rahman_joy,
Just to add:
${…} references always refer to the “name” column (in survey as well as in choices).

1 Like

Thanks a lot… :+1: :+1:

1 Like

Hi @Kal_Lam

How can I use a “select one” question that lists the variable names and not the label?

All Best

Could you provide more details and an example, please, what you exactly want to do?

In a question “select one” list zip code. In another “select one” question in cascade it would list the corresponding city. Name = Zip Code and Label = City.

Sorry, could you provide a full example, please, with names and labels of the two related choice lists?

Maybe the Help Center articles could help you too:
Adding Cascading Select Questions — KoboToolbox documentation and
Including P-Codes in the Output Data — KoboToolbox documentation.

As far as I know, you cannot show names of variables and choices in your form, on the screen. Only labels and values. So, another option might be to include the zip code in the city label.

1 Like