Survey123 - Trying to pull data of previous answer

511
5
02-09-2024 02:16 PM
constellationshire
New Contributor

Hello,

I was building a survey and wondered if I could do the following:

I have a select_one which determiens a type of object I will be capturing information from

  • if I select object_1, then I'll be collecting some info with items such as object_1_characteristic_1, object_1_characteristic_2, object_1_characteristic_3, etc
  • if I select object_2, then I'll be collecting some info with items such as object_2_characteristic_1, object_2_characteristic_2, object_2_characteristic_3, etc

There is a relevant ${object} = 'object_1' for example, so that only the relevant question and answers for each object appear.

My question is, is there a way to have a note at the bottom, that will capture a different data captured earlier?

Ideally, I wanted to have something like $(TYPE_OF_OBJECT_characteristic_1), where the TYPE_OF_OBJECT is a variable (object_1, object_2...). However, it seems that these placeholder values after a dollar sign do not accept a variable string inside, only a hardcoded one.

Do you think is there a way I could have a sort of $(VARIABLE_DATA_HERE) type of placeholder, where the data is selected based on a previous select_one question?

Thanks a lot,

5 Replies
ChristopherCounsell
MVP Regular Contributor

I don't understand half of what you are trying to achieve. You're locking them into selecting one, but want to track if they change the selected value? This is an illogical workflow.

Two things that may help you achieve your result:

  • select_multiple choice_list - this will let them put in one or more characteristics
  • selected(${question_one}, 'a') - this relevant expression will hide the questions unless 'a' is selected

If you want to preserve values (if you're editing existing data) you can use the body visible parameter instead of relevance. 

 

0 Kudos
abureaux
MVP Regular Contributor

Ya, a little more detail may help. Could you provide some screen caps?

At first I was thinking this was a case of needing jr:choice-name(), but upon re-reading there is definitely a different need here.

0 Kudos
DougBrowning
MVP Esteemed Contributor

No a field name cannot be dynamic like that in almost all programming languages.

Only idea is to use if.  Something like if(object_1 selected, use object1, if(object_2, use object 2, etc.  You could put this is a calculate type field then use that field for the rest of the form.

So your form would have a new field like "DataToUse" and it has the if calc above.  That way it always has the data you want in it.  Then just use this "DataToUse" for the rest of the form.

Hope that works

0 Kudos
constellationshire
New Contributor

Here is an example of what I want to achieve:

Let's say I have this survey:

constellationshire_3-1707754692039.png

And my choices:
constellationshire_1-1707754162040.png

And the extra .csv to look what the actual questions are, since I cannot query the labels or hints with a formula:

constellationshire_5-1707754934074.png

 

 



The way this would work, is that I choose what type of component I want, and depending on that a series of attributes for each component will appear.

All of the "text" fields have a "null" bind::esri:fieldType so that they do not get captured on the survey.

I want, however, to capture the responses using a calculation.

1. Regarding the questions, it's easy because I can make a database and then run a pulldata based on a variable input (which changes based on the select_component)

2. Regarding, the answer, I cannot make something like ${VALUED IS BASED IN ${PREVIOUS VARIABLE}} type of field.

The workaround is to concatenate all the answers, each answer from a different component, what will result in the concantenation of empty strings and the string I want.

The reason I was looking at this approach is that I have a very large databse of objects and characteristics and I am running into the approximately 500 column limit, but a given component usually has 10-20 attributes to be recorded. If I can reconstruct the  questions and answer with a calculation, that would be great.


EDIT: wrong pics posted

0 Kudos
DougBrowning
MVP Esteemed Contributor

You could try to put the concat in its own field then use that field in the pulldata.  But I am not sure you can pulldata on a form you have open.

Another idea is to make the labels dynamic instead.  So you have field_1, 2, 3 for the name column then put a calc in label to show the user what name you want to show the user.  I think you can put ${field} in a label.

0 Kudos