How to get calculations from embedded data to appear in text box | XM Community
Skip to main content
Is it possible to get the calculated annualized returns to display in the last column of my question, after the respondent has entered the quarterly returns within the same question? I created the embedded data in the Survey Flow section, as well as the math operations to get the computed returns (see below screen shot).

!





However, when I used the Add Default Choices to enter the piped text, nothing shows up. Am I doing something wrong? Below is what the survey question looks like when I entered the other other numbers. You will notice that the last column remains blank, which should be displaying my calculations.

!



!
I'm guessing that your embedded data block is either before or after the block that has these questions. Embedded data math operations don't calculate immediately, but execute from the specific spot in your flow. If you have it before the question block, it'll read that math but the fields will be empty. If you have it after the question block, the field will be filled after the respondent finishes the question block (and hits next, etc).



So if you're looking to have something calculate on-the-fly, you'll probably need to turn to Custom Code.



Alternatively, you can store the values, then present the table again with the values filled and it will show correctly in your computed return field.
@jpardisusick - thanks! My embedded data block is after the question block. I tried your 2nd suggestion and presented the table again. However, now I'm getting the word 'invalid' in the last column.

!
> @oakinlotan said:

> @jpardisusick - thanks! My embedded data block is after the question block. I tried your 2nd suggestion and presented the table again. However, now I'm getting the word 'invalid' in the last column.

>

>

Please check your Math operation syntax
I agree with @Shashi: Looks like there's something a little wonky in your math operation. Check your syntax with the area circled in red. You have to declare the field too, not just the question number:



!







See how it's named here:



!
Hmmm...I thought I did declare the fields. Q118 is the field name I declared for the 1st quarter return, Q218 is the field name for the 2nd quarter return, and so forth (Those fields are not question numbers). I assigned the entered text from each question to these fields. Was that wrong? Below are the steps needed in order to get the computed return:



* First, each quarterly return is divided by 100, then increased by 1 (i.e. - 5.23 / 100 + 1 = 1.0523)

* Next, multiply each de-annualized return by each other (i.e. - 1.0523 * 1.0325 * 1.0136 * 1.0145 = 1.1833)

* Subtract 1 from this number (i.e. - 1.1833 - 1 = 0.1833)

* Lastly, multiply by 100 (i.e. 0.1833 * 100 = 18.33)
Gotcha, field name instead of question number. It looks like the field name is still not complete though. Try using the 'insert piped text' when you're building your formula and input your Embedded Data names from there. It'll put the necessary code in so that Q will read it as an Embedded Data field and compute correctly.
> @jpardicusick said:

> Gotcha, field name instead of question number. It looks like the field name still not complete though. Try using the 'insert piped text' when you're building your formula and input your Embedded Data names from there. It'll put the necessary code in so that Q will read it as an Embedded Data field and compute correctly.

>



I used the 'insert piped text' and it now works! Thanks SO much!!!!

Leave a Reply