Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Inserting variables in IF formulas - keeping variables alive

More
11 years 5 days ago #112086 by tgrecu
Please take a look at this formula i'm trying to implement.

{if(Q1 == 0, "you answered Q1.shown and this is wrong","you answered Q1.shown and this is correct")}


If the answer has value 0 the answer is wrong and i want to show some text containing the variable Q1 so that the selected answer is displayed.

Problem is, i can't find a way to make the EM understand Q1 is a variable when i put it inside the "quotes"



I found very long workarounds, so i'm asking if any of you knows how to keep variables alive inside of columns, when using formulas.
The topic has been locked.
More
11 years 5 days ago - 11 years 5 days ago #112089 by fransmarcelissen
Hi Tgrecu,
I always use
{if(Q1 == 0, join("you answered ",Q1.shown," and this is wrong"),
join("you answered", Q1.shown," and this is correct"))}

but sprintf (see www.limesurvey.org/manual/Expression_Manager ) or implode(' ',.....) should also work.

Succes
Frans
Last edit: 11 years 5 days ago by fransmarcelissen.
The following user(s) said Thank You: tgrecu
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose