Calculating an associated value from select_one

1. What is the issue? Please be detailed.

I am trying to generate a value for a note from another column in a choices-list. Here are my columns

list_name name label geometry fid Section image
images item1 12345.jpg [redacted] 1 1 12345.jpg

I am using the following calculation (my select_one is called ImageID):

instance('images')/root/item[name=${ImageID}]/fid

This works fine and returns the number 1. Likewise /Section works as expected

However, if I want to get either label or image column the calculation returns nothing. I am sure have used instance('images')/root/item[name=${ImageID}]/label in the past, but can’t find the form where it worked! It seems counter-intuitive for a ‘recognised’ column name not to follow the same pattern

If I add a column called filename and duplicate the data from the image column, the calculation instance('images')/root/item[name=${ImageID}]/filename returns 12345.jpg

Am I doing something wrong or is this a new feature? Can’t find anything in the docs with a caution of this issue.

2. What steps can we take to reproduce this issue?

create a select_one with name ImageID and the choice-list as above. Use map appearance if you have geometry or no-buttons to see the image(s). Be sure to upload the image(s) to Central!

create a calculate row with name ImageCalc and calculation: instance('images')/root/item[name=${ImageID}]/labelyou can add the trigger as ${ImageID} if necessary.

create a note row with label ${ImageCalc}

3. What have you tried to fix the issue?

Created a duplicate column as described above

4. Upload any forms or screenshots you can share publicly below.

Peep this thread and @LN s explanation

Ah, thanks. We’ve both found similar issues here, and I went round and round trying to find a mention of a static column in the choices sheet…

I think the docs talk about columns in the SURVEY sheet as being static or dynamic, but not explicitly that you can’t access certain columns from the CHOICES sheet?

@ln Maybe a good place to note that would be https://docs.getodk.org/form-logic/#dynamic-defaults-from-form-data and specifically after the section “XLSForm that looks up default values based on a selection”

I came to the same work-around as you (parallel evolution?) but wish I’d found that post before losing hair and sleep over label and image being ‘inaccessible’ :slight_smile: - I was using your showcase about images as a model (although I just want to display them in a note, rather than mark up). Next time I’m doing a search of the forum for any post by you (that’ll take me a while to sift :slight_smile: ) - so I can use Andrew Intelligence to help!

As always, thanks for the guidance.

As an update - I checked one of my other forms and can confirm that when working with ENTITIES, you can reference the label using the instance method described above - this is what confused me: that it doesn't work consistently with the CHOICES sheet... Probably a very good reason for it, but I couldn't find that reason.

I keep confusing myself when recalling which datasource (internal choice / CSV / entity) behaves in what manner, but is that because internal choices work with image/big-image, but entities don't (i.e. you won't get an image against your select) internal choices creates the "special" XML in the definition but an external select like a CSV or entity won't have that?