Problem with math operator used as embedded data | XM Community
Skip to main content

Dear community members, I would like to ask you for any advice regarding the problem with the usage of math operator for embedded data.
I just want to create a simple index by computation of the value of three responses and saving this value as embedded data for future use.
I created the foloving equation in the survey flow below source variable:
NormativeTrust_CT (set to number, but I tried also version without setting any variable type) = $e{ ( q://QID3/SelectedAnswerRecode/1 + q://QID3/SelectedAnswerRecode/2 + q://QID3/SelectedAnswerRecode/3 ) / 3 }
Despite repeated consultation with the manual (e. g. https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/piped-text/math-operations/) and forum, countless attempts of equation modification and check source variables in the survey project, I'm not able to get more than empty embedded variable NormativeTrust_CT in the data file.
Thank you for your advice.
Lukáš

Lukas_S How is your survey set up? What question type are you using - are you trying to make a calculation based on a single, multiple choice question? You seem to be referencing the same question 3 times in your calculation. If you're using a multiple choice question, then my first thought is that you need to say "SelectedChoices" instead of "SelectedAnswer." So the piped text for a multiple choice question would be more like:

q://QID3/SelectedChoicesRecode
...but then, that might not be the question type you're using


https://www.qualtrics.com/community/discussion/comment/38291#Comment_38291lizb311 Thank you for your answer. To answer your questions, I'm using single-choice questions (3 in 1 matrix table) with a forced response. This battery is displayed if the respondent previously marks XY as important in another question.
obrazek.pngMy goal is to create the index ((numeric value of the answer of question 1 + numeric value of the answer of question 2 + numeric value of the answer of question 3) / 3). All answers have set numeric value:
obrazek.png I tried to use your suggested piped text based on the "selected choice" expression, but my embedded variable still does not work.
I will be grateful for any further advice.
If something is still unclear, I will do my best to clarify.


Lukas_S That was helpful! If you're using a matrix, then you were right to use "Answer" instead of "Choice." So I recreated what you were trying to do, and actually ended up with the exact same calculation that you had. In short, you just need to make sure that your blank spaces are actually blank spaces and haven't been automatically converted into HTML

 

So the correct calculation is this (looks the same as what you originally had):
$e{ ( q://QID3/SelectedAnswerRecode/1 + q://QID3/SelectedAnswerRecode/2 + q://QID3/SelectedAnswerRecode/3 ) / 3 }

I set up a test in my survey to make sure it would work - I added this descriptive text to check if it was correctly interpreting the recode values, if it would calculate the average correctly using only piped text, and if it would calculate correctly via embedded data. This is how I set that up in my survey builder:
image.pngAnd here's what my survey flow looked like:
image.pngAs I said, at first, it didn't actually work for me, either. So in the descriptive text I made in the survey builder, I switched to the HTML view. If you do that, sometimes you'll see that it automatically translates spaces into the HTML
 
- and that is what messed up the calculation. So go to HTML view, and anywhere you see
 
erase it and type a blank space instead. If you have a lot of formatting, you might need to click the "remove formatting" button, too.
image.png
Once you've made all the edits, copy and paste that corrected version into your survey flow. That worked for me, to make sure that the blank space issue was resolved.
And then it should work! Here you can see in a Survey Preview, I selected what should be all 5's:
image.pngAnd these are the results I see on the next page:
image.png


lizb311 Thank you very much for your help and effort.
I replicated your process and it works.
The strange thing is that there were no   spaces when I copied my calculation from the embedded data editor to the survey builder (and checked in HTML). Regardless of this, I copied the calculation back and tried to create your "Embedded data check" and it works correctly.
The only thing I'm still wondering is that when I test this calculation via "preview" of my survey then I can found the numeric value of my embedded data variable in the data file but when I try to fill the survey via "Anonymous Survey Link" (in section Distribution), then my embedded data variable is empty. It leads me to question if I can be sure that it will work correctly during real data collection. Do you think, what can be the reason for this "double behaviour" of the survey? Could be the reason the fact that my survey is still a "draft" and therefore do not work perfectly when I'm using the second type of preview (via anonymous link)?
Thank you once again!


Lukas_S If it is working correctly via the Survey Preview but not working correctly with the Anonymous Survey Link (from Distributions section), then yes, I think that would be because your survey is in a draft state. The Survey Preview will by default show the current version (with all recent, unpublished changes), but the Anonymous Survey Link will show the last published version.
If you take out the text

&Q_SurveyVersionID=current
from the Survey Preview URL, then you will be previewing the last published version instead of the current version. That should make what you see through your Survey Preview link match what you see through your Anonymous Survey Link. You can try taking that out from the Preview URL and see what happens to your embedded data field then, if you want to check that.


https://www.qualtrics.com/community/discussion/comment/38331#Comment_38331lizb311 Thank you very much for your explanation; it works exactly you described.
Thank you for all your great and valuable advice. It helped me a lot.


Leave a Reply