Hi there,
Let’s say I’m asking in Question 1 “Are you a dog or a cat person?”. Choices are coded this way: 1 = dog / 2 = cat. Question 2 then should show as “Do you have a dog?” or “Do you have a cat?”, depending on the answer given in Question 1. How am I able to do this on Excel? I’m currently labeling Question 2 this way: “Do you have a ${Q1}”. But it shows me “Do you have a 1?” or “Do you have a 2?”, depending on the answer given in Question 1. How do I show the label instead of the value of Q1? Please don’t tell me to simply decode choices, because in my real survey I do need them to be coded. I’ve read about function choice-label() but it does not seem to work or I’m doing something wrong.
Thank a lot for any help!
@Olivia, you could do this as outlined in the post discussed previously:
Thank you, works perfect
Hi @Kal_Lam , I’m not able to download the XLSForm you shared. Please, can you help me get it ?
I’m also looking for the way to display the label instead of the value of a select_one question.
Thanks.
Welcome to the community, @francis_houeha! You will need to go to this topic Freeze a text based on the currency entered to download the XLSForm.
@Kal_Lam
Many thanks for your efforts.
Can we get the labels of a certain choice from a specific language.
Where to add language code option to the calculation (jr:choice-name).
Best
Ali
thank you for your excellent work.
HI @Kal_Lam , i have a similar situation. I have a parent form which has select one questions which return the block, panchayat and village. When i try to use this data in a child form through dynamic data attachment, i get the names instead of labels. For examples, it is not showing the village name as xyz, but shows the number like 922. I want the child form to display teh label text instead of numerical names when dynamically attaching data. Thanks
The specific labels that were used to display a select-one question (in your parent form) do not ‘follow’ the submission; the submission data just stores the raw string values. That’s what you are seeing in your child form.
If you want to re-display the original labels then you’ll have to basically mirror the exact same select choices list in your child form, and then use the jr_choice-name() to look them back up in the child form.
Many thanks @Xiphware. I tried the jr choices route also. It did not work. Only three out of five variables work. I Am attaching screen shot child form here (not able to upload more than one…I will upload parent form and enketo forms in the next two messages)
![Screenshot
Please help
Can you please post both your forms (suitably redacted if necessary). I’m not 100% sure from above who is the parent vs child, and how they are supposed to interact in your workflow. Thanks.
Child.xlsx (23.3 KB)
Parent.xlsx (22.7 KB)
Uploaded here @Xiphware. Thanks for your help
what does your child’s xml-external
file formcb1.xml look like? Can you upload an example of it.
How to download this xml file? from where. I am sorry, I am not able to see this. I am not sure you want, but I am attaching the xml file I fo
adEunmT7Ms3z4zBp3S3E7E.xml (122.2 KB)
und that of the form itself
Your child form references an external dataset file (specifically, an xml-external dataset)
from which you are then pulling out values in subsequent calculations. But without knowing the exact format of this file its not possible to determine why these external file lookups might be working in some cases but failing in others…
However, what I suspect is that you are using the raw submission XML data from your parent form (?!) as the xml-external dataset file for your child form [the implied structure of the XML suggested by your instance() lookup calculations would seem to match what the parent’s XML submission data might look like…]. If that is in fact the case, then you might be referencing the wrong XML element names in some cases, resulting in the associated calculations returning nulls. Specifically, these might be the culprit:
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/block
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/panchayat
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/village
since the actual XML element names in the parent form for these fields are: blockc
, panc
and villc
So I might suggest changing your child form to:
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/blockc
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/panc
instance('formcb1')/root/data[farregistration/farmerida=current()/../farmerid]/farregistration/villc
and seeing what happens. Again, this is just conjecture on my part; without knowing what your actual formcb1 XML file looks like its impossible to tell.