Using multiple columns as primary key [ or key columns] in pulldata()

My fellow ODKians,
Hope everyone is having an amazing week. I am slightly lost in finding a way to use multiple key cols in pulldata. A simple usecase is: Pulling firstname from 'household csv', key columns are: 'member_num' and 'member_id'.
pulldata query would look like" pulldata('household_csv', 'member_key', 'fname', ${ODK_value})
where member_key = member_num and member_id.

However, this is not possible in given constraints for pulldata from xlsform or odk official documentation.
Is there a logical reason why is it not possible for pulldata to have primary key consisting of multiple column?

Any feedback appreciated.
Thanks,
Jordan

Hi Jordan,

Pulldata() unfortunately has it's limits. Usually for something like this I use an Xpath. That way you can have as many criteria as you want and you can pull the label rather than the name if that suits you.

It might look something like this but I didnt fully understand the desired logic so you might need to adapt:
instance('household_csv')/root/item[member_num=${member_key} or member_id =${member_key}]/name

This type of XML is really quick to learn and quite powerful. You use it in the calculation column of your XLSform (assuming that is how you are building your form).

I have similar scenario,
Suppose you have a CSV file named "data.csv" with the following content:

medication dosage patient_type
Aspirin 100mg Adult
Paracetamol 500mg Adult
Ibuprofen 200mg Adult
Benadryl 25mg Pediatric
Amoxicillin 250mg Pediatric

In XLSForm, how can I use pulldata with two conditions to retrieve the dosage based on the medication and patient type.

Try replacing pulldata with an instance lookup like this that has an and to match two values

instance('data')/root/item[medication=${selected_medication} and patient_type=${selected_patient}]/dosage