Inserting variables in IF formulas - keeping variables alive

More
3 years 1 month ago #112086 by tgrecu
tgrecu created the topic: Inserting variables in IF formulas - keeping variables alive
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.

Please Log in to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #112089 by fransmarcelissen
fransmarcelissen replied the topic: Inserting variables in IF formulas - keeping variables alive
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 manual.limesurvey.org/Expression_Manager ) or implode(' ',.....) should also work.

Succes
Frans
Last Edit: 3 years 1 month ago by fransmarcelissen.
The following user(s) said Thank You: tgrecu

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now