Text substitution within questions using formulae

For text substitution we use a %%[ ] 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.

 

A common use for work using prices is to use the PRETTY formula 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)]

 

 

Showing code-text instead of codes

 

Note that if you have a coded age question where 18-24 is code 1, then

 

Are you really %%[age]?

 

would show the following because %%[age] returns the code selected for age

 

Are you really 1

 

To get the text for a code, not the selected code use the more complicated

 

Are you really %%[GETTEXT(age,@age)] ?

 

Which converts the code 1 for age into the code text for item 1 from the @age 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’)]

 

Note that all calculation formulae are written in upper case, so it is often clearer to use lowercase for the question names

 


Previous article: Routing - the PageBreak question revisited Next article: List questions and List manipulation
More details

Go to Notanant menuWebsite accessibility

Access level: public

Page feedback

This site uses essential cookies only. By continuing to use this site you accept our use of cookies: OK
Show or hide the menu bar