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

  • tgrecu
  • tgrecu's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months 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.
  • fransmarcelissen
  • fransmarcelissen's Avatar
  • Offline
  • Premium Member
  • Premium Member
More
9 years 6 months ago - 9 years 6 months 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 manual.limesurvey.org/Expression_Manager ) or implode(' ',.....) should also work.

Succes
Frans
Last edit: 9 years 6 months ago by fransmarcelissen.
The following user(s) said Thank You: tgrecu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose