Dynamic selects with the search() expression

Hello colleagues, I am developing a student attendance form and want to pull data from a beneficiary registration dataset saved as a .csv file. I have read all of the forum descriptions on using pre-loaded data and dynamic selects. Here is the relevant survey capture:

And the relevant choices capture:

With the search expression on line 17, column G, I intend to pull data:

  • From a .csv file named ‘benregistry’ and where;
  • The EMIS number in the column ‘emis’ in the .csv file matches the EMIS number in the previous form item ${emis}
  • The grade level in the column ‘grade’ in the .csv file matches the grade level in the previous form item ${grade}
  • With the hope of eliciting a list of student names by that grade in that school to select to record the attendance for each month

I have gotten the pulldata() function to work for a couple of the items in the form. However, the search() expression as indicated above only renders as follows on Enketo:

In other words, instead of rendering a list of student names, the choice that is offered is the label name in my choices sheet. It’s my understanding that the “name” and “label” in the choices sheet are to refer to the column names in the .csv file from which I am pulling.

Any help or identification of something that I am doing incorrectly would be greatly appreciated!

Thank you,
Clay

Choices capture:
image

Enketo render:

Hi @claywestrope
Welcome to the community.
Reading through your issue, there are a couple of things that you may not have configured right.

  1. You are assuming that the Pull Data functionality would work on pulling the entire list of choices from the CSV to appear as items in the choices sheets. *This is a wrong assumption since pull data only works as per what is in the article as well as how you have applied it correctly in Row 18.
  2. You should actually have the name of the students in the choices sheets and set the appearance to be search as you had tried without the formula for pull data in the field (this is not the correct application)

Advice if the corrections work for you.

Stephane*

1 Like

Hi @stephanealoo,

Thank you for you swift response and welcome to the community.

I have read through your advice and am not sure I understand what your are suggesting. My issue is with the search() expression (not the pulldata() expression). As you see on line 17 of the survey tab, I am attempting to write a search expression that:

  • Pulls from the ‘benregistry’ .csv file
  • The names in the ‘benregistry’ .csv file (column ‘benname’ in the .csv file) are listed as options filtered through the search term by:
    • Matching the EMIS number in the .csv file (‘emis’) and EMIS number in the previous section of the survey (${emis})
    • Matching the grade level in the .csv file (‘grade’) and grade level in the previous section of the survey (${grade})
    • The choices list_name stuname has the unique ID from the .csv file column (‘benid’) and matched student name from the .csv file column (‘benname’).

What I want is a list of student names from which the enumerator can select for each grade level in each school to record attendance for each child through a repeated group.

Please let me know if you have further suggestions based on this additional explanation.

Thank you,
Clay

Hi colleagues,

Does anyone have any creative thoughts on the issue outlined above? I am hoping to have this resolved by midweek, if possible. Your help is greatly appreciated!

Best,
Clay

Hi @stephanealoo and @Kal_Lam,

I have noticed that you have quite a bit of experience with the search() expression in KoBo. Would you be able to help me identify where I might be going wrong in the above form. I would very much like to figure this out this week, if possible.

Thank you,
Clay

Hi @claywestrope,

Would you mind sharing with us your xlsform along with the csv file so that we could have a closer look at it. You could use the private message if you feel your survey tool should be treated with confidentiality.

Have a great day!

Continuing the discussion from Dynamic selects with the search() expression:

Hi @Kal_Lam and @stephanealoo,

Attached are the xlsform and csv file (with dummy data for the names). I appreciate any help you can provide identifying where I might be going wrong!

Thank you,
Clay

LEARNAttendance_Sep-Dec2019_18Feb2020.xlsx (33.7 KB)

benregistry.csv (3.0 MB)

Hi @claywestrope
I made some slight change on your XLS form

Note the change on the pull data functiona and the csv
benregistry.csv (3.8 MB) LEARNAttendance_Sep-Dec2019_18Feb2020.xlsx (34.2 KB)

The search function should be able to work with the minimal search option you included. Note that we have other search () options that are not documented such as:

  • startswith
  • endswith
  • contains
  • matches

Stephane

Hi @stephanealoo,

Thank you for your response. The changes you made work well for the first pulldata() option. However, the names are still not showing up as selections for the “stuname” variable with the search() option. Please see the screenshot below of how this renders in Enketo (this is the same issue as before). I appreciate any guidance you or anyone else can provide.

Best,
Clay

Hi every one!

As far as I could research, the search() function (as per its specification in XLSForm) is not supported by Enketo. You only have a “search” feature in the “appearance” field that allows you to narrow down the search in a long regular choice list (the Google predictive typing way…)

Cheers!

1 Like