Select the first item from a list question

I am trying to capture the first name from a list of HH members and I am missing something in my syntex

DEM_NAM.Select.(d=>d.@rowindex==1).First(p=>p.Item1==@rowcode).Item2

to use in a variable for the respondent in a labour force survey

neville

If the person’s name is asked as a question in the roster, then something like this should give the name of the first person: PERSONS.First().PersonName

Thanks Sergiy,

That isn’t my situation exactly, I have a list question(DEM_NAME) that is used as the source of my household demographics roster. Instead of the head of household being first in my HH members list I have the respondent. So I ask the HH members there relation to respondent. I modified your code and I almost have what I need.
DEM_NAM.First().ToString()

and that gives me the following:


So from my test Nev is the respondent so for everyone else question A.4) should have Nev
not 1-> Nev. I think I am bringing the rowindex and item in the first row of the list. How do adjust my syntax to only get the content of the first row of my list (Nev in this case).

Neville

Dear Neville,

try DEM_NAME.First().Text, which should give you the name of the first person in the list question DEM_NAME.

See e.g. this text for the First() method. You could also use Item2 instead of the Text with the same effect (which is what was used in the earlier syntax), but Text is easier to read and remember. You could also use the Item1 or Value to obtain the numerical code of the person as it will appear under the @rowcode reference in the roster triggered by this list.

But I wouldn’t rely on that. I’d rather get the list of all household members (in any order as convenient for the respondent), then mark with linked questions “Who is the respondent?”, “Who is the head?”, etc. (Where “who…” is interpreted in fact as “which of the above listed members…”) this is especially good if your respondent may change. But you decide depending on the realities of your survey. If you pursue this approach, just include the linked question value as a usual substitution: “What is the relationship of %rostertitle% to %hhhead% ?

Thanks,

DEM_NAME.First().Text works as I want.
I am using the linked question with substitution.

Regards

Neville