Calculate embedded variable name | XM Community
Skip to main content

Hi guys,
I have a situation where I call a web service which returns five results which get stored in embedded data with the following names:

  • prediction.0.formatted_address

  • prediction.0.place_id

  • ...

  • prediction.4.formatted_address

  • prediction.4.place_id


I then display each of the formatted_address values as a multiple choice question which is allowed only one response. I have recode values set to the values of 0, 1, 2, 3, and 4 for each selected response.
I want to use the place_id in my next query to a web service, however I am struggling to calculate which embedded data variable to use.
For example, should the user select
prediction.0.formatted_address
I would like to then send
prediction.0.place_id
to the web service.
I have tried calculating this using piped text to do this, but I keep getting stuck.
I thought that something like the following would work, but I don't seem to be able to get it right:
${e://Field/predictions.(q://QID7/SelectedChoicesRecode).place_id}

Any tips? Is this possible?
Recode values would be great, but it only accepts integers so I can't set the value to be the place id.

Hi,
If you concatenate these variables together in the survey flow then it should work.
So if you set a variable called "Output" in this example with the following formula:
predictions.${q://QID7/SelectedChoicesRecode}.place_id
Then if they select the option that correlates to re-code=0 then the output will be this:
predictions.0.place_id
So your pipe in the web query will be - ${e://Field/Output} 
QualtricsHelp1.pngHope that helps!


Thank you for your help.
I tried this an it concatenated the text just as I need.
Is there a way of evaluating this concatenated string to select the value of that field by the name? For example, if I have a field named

predictions.0.place_id
which has a value
ABC123
how do I use the concatenated key to get the value?


Leave a Reply