# Referencing dataset - label from select\_one as text in next question

**URL:** <https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467>\
**Category:** Support\
**Created:** [November 3, 2022, 3:32pm UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467 "2022-11-03T15:32:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seewhy](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/seewhy/32/3199_2.png) [@seewhy](https://forum.getodk.org/u/seewhy)\
**Post date:** [November 3, 2022, 3:32pm UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467/1 "2022-11-03T15:32:48Z")

</div>

**1. What is the issue? Please be detailed.**  
In my form I have an external csv select\_one\_from\_file question and a subsequent text question. I am using the appearance map and it works great!

I would like to set the default for the text question to be the label for the select\_one (this is essentially an opportunity to update the existing description if necessary)

The select\_one\_from\_file works (so I know it is correctly set up)  
The next question remains blank.

In the example within the sample xlsx I'm using the select\_one question is called Surfacing1  
In the column for default of the next question I am using: instance("surface")/root/item[name = ${Surfacing1}]/label

which in my naive understanding of XPath should evaluate to the label of the item corresponding to the value Surfacing1 from the list\_name surface...

I am also trying to reference other columns in the csv, but they don't work, so let's just start with the label...

I've also tried it with an internal list as select\_one (appearance minimal) and get the same result - blank next question.

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

I produced a skeleton form but it doesn't parse, so I'm a bit stuck. And yet the big form (which I'm not sharing) validates fine. Which is a bit odd. I tried adding choice\_filter True() to the skeleton just in case but no joy

Response from Central and XLSForm online  
Error: ODK Validate Errors:

> > Something broke the parser. See above for a hint.  
> > org.javarosa.xpath.XPathMissingInstanceException: XPath evaluation: Instance referenced by instance(surface)/root/item/label does not exist

The following files failed validation:  
${select-one-label}.xml

Result: Invalid

Maybe if I can get to the bottom of this, it might help? No idea why one would work and the other not!

**3. What have you tried to fix the issue?**  
followed the documentation: [https://docs.getodk.org/form-datasets/#referencing-values-in-datasets](https://docs.getodk.org/form-datasets/#referencing-values-in-datasets)  
This even has the example of picking up the label from an external dataset, so I used this as the model...

I have been able to use the following question to show the value in a label, but not set the default value of the question: [Referring to a label of an answer to previous choose one question, within the label of subsequent question](https://forum.getodk.org/t/referring-to-a-label-of-an-answer-to-previous-choose-one-question-within-the-label-of-subsequent-question/24780)

This doesn't really solve my problem and adds extra columns to my dataset, so I don't see it as a viable answer...

**4. Upload any test forms or screenshots below.**  
I'm using ODK Central 1.5.3 and ODK Collect v2022.3.6  
[select-one-label.xlsx](https://forum.getodk.org/uploads/short-url/1D5zJeqtOsybLcsHS3gtwrtXSkg.xlsx) (12.0 KB)

Any help gratefully received. No doubt it will be the usual problem of a minor error that I can't see for looking at.

---

<div class="post-metadata">

**Author:** ![janna](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/janna/32/3441_2.png) [@janna](https://forum.getodk.org/u/janna)\
**Post date:** [November 3, 2022, 4:15pm UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467/2 "2022-11-03T16:15:37Z")

</div>

Hi there @seewhy!  
A couple of resources that might be helpful to you - sorry, just have taken a quick look at this, but let us know if this doesn't exactly match what you need:

ODK Docs - check out [https://docs.getodk.org/form-logic/#dynamic-defaults-from-form-data](https://docs.getodk.org/form-logic/#dynamic-defaults-from-form-data) for using the 'calculation' column & 'trigger' column for getting default data from form responses (as the 'default' column only calculates at form creation)

Also - if you look about halfway through this video on select\_one\_from\_file - shows the xpath being used in a 'calculation' question - if it's helpful. [https://youtu.be/yiRsH1vvcBU](https://youtu.be/yiRsH1vvcBU)

Hope this helps?  
Janna

---

<div class="post-metadata">

**Author:** ![seewhy](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/seewhy/32/3199_2.png) [@seewhy](https://forum.getodk.org/u/seewhy)\
**Post date:** [November 3, 2022, 5:18pm UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467/3 "2022-11-03T17:18:18Z")

</div>

Thanks @janna

I knew it would be a simple error. The connection between default value and triggering an update wasn't on my radar! I think I've actually done that before but it didn't trigger any neurons this time around. At least this is on the forum now - I like the way that the Docs cross reference things, so a link between the reference I used and the one you provided would be a good one to help other fools like me 🙂

And to clarify, what I did was to move the expression

instance("surface")/root/item[name = ${Surfacing1}]/label to a column called Calculation

and

add a column called trigger and inserted the value ${Surfacing1}

And it works - so now I can pre-fill other questions based on the selection on a map and other columns on my external CSV file. Happy days!!!

As always fast and fabulous support from the ODK community.

---

<div class="post-metadata">

**Author:** ![janna](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/janna/32/3441_2.png) [@janna](https://forum.getodk.org/u/janna)\
**Post date:** [November 3, 2022, 5:27pm UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467/4 "2022-11-03T17:27:29Z")

</div>

woot woot! I have totally been in exactly your situation with this very 'dynamic default' question before...lol... 🤦‍♀️

---

<div class="post-metadata">

**Author:** ![seewhy](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/seewhy/32/3199_2.png) [@seewhy](https://forum.getodk.org/u/seewhy)\
**Post date:** [November 4, 2022, 10:33am UTC](https://forum.getodk.org/t/referencing-dataset-label-from-select-one-as-text-in-next-question/39467/5 "2022-11-04T10:33:07Z")

</div>

Can I make a suggestion for the Docs:

In the section [https://docs.getodk.org/form-datasets/#referencing-values-in-datasets](https://docs.getodk.org/form-datasets/#referencing-values-in-datasets) I would recommend adding something like the following after the last paragraph (maybe as a 'tip')

If you want to pre-fill data in your form on the basis of a selected value you need to use dynamic defaults so that other fields are updated when the "parent" item is changed. You can use this with internal choices, external CSV or GeoJSON files. Please see [https://docs.getodk.org/form-logic/#dynamic-defaults](https://docs.getodk.org/form-logic/#dynamic-defaults) for details

Other wording is available 🙂
