Text substitution within questions using formulae
Text substitution or 'piping' is used to bring an answer from a previous question into a new question. For instance, what is your favorite brand? Followed by 'Why do you like %%[brand]?' which would show the name of the brand previously mentioned.
Cxoice includes full text substitution and calculations. For text substitution Cxoice uses %%[ ] to enclose the formula within the text of a question or as code text. For instance
You said %%[MyText]. Why did you say that?
would return the value for the MyText question.
For more advanced uses, you can also use conditions like IF and include calculations – for instance
%%[IF(COUNT(items)=1,’which one’,’which ones’)]
For questions involving prices and price calculations, a useful formatting formula is to use PRETTY to ensure displayed prices are shown in an appropriate way – with two decimals if below 200, or with no decimals if larger
Would you buy at the following price $%%[PRETTY(baseprice*1.333)]
Available formula, including selecting items from lists are shown in the Formulae Appendix. All formula are always in uppercase to distinguish them from question names.
Showing code-text instead of codes
One technical issue to be aware of is that questions normally record as codes. For instance a question called ageband might have 18-24 as code 1. If you try to use the text substitution %%[ageband] as follows
Are you really %%[ageband]?
then the question would show the following because %%[ageband] returns the code selected for age, not the text description
Are you really 1
To get the text description for a code requires the slightly more complicated formula
Are you really %%[GETTEXT(age,@age)] ?
Which converts the code 1 for age into the code text for item 1 from the @age question.
If you're not sure what calculations the formula is doing, use %%DEBUG[...] in place of the %%[...] options and you will see the formulae and calculations in the browser console (select the Web developer or 'inspect' option in your browser to see the console).