Welcome to the LimeSurvey Community Forum

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

Is it possible to create new variables?

More
9 years 4 days ago #118295 by rcwd
I need to group some results in end message.
Is it possible to create variables?

What i want to achieve is in like this:

{
MYNEWVAR_1 = countif( 'AAA', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)
MYNEWVAR_2 = countif( 'BBB', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)
MYNEWVAR_3 = countif( 'CCC', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)

if(MYNEWVAR_1 > (MYNEWVAR_2 + MYNEWVAR_3), 'hello world!', 'bye bye' )
}
The topic has been locked.
More
9 years 4 days ago #118299 by Ben_V
Replied by Ben_V on topic Is it possible to create new variables?
1 variable => 1 equation type question

As answered in your other similar post , you have to previously create equations to sum your responses.
After ou will be able to display a message a message using EM or Javascript; I don't know how it is possible to sort (up or down) numeric results using EM except doing substractions (it's ok for 2 or 3 numbers) and that's why I've indicated you a js method (the only way i know to sort more numbers).

Re-using your example you need:
a) 3 questions to set your variables
MYNEWVAR_1 => {countif( 'AAA', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)}
MYNEWVAR_2 = {countif( 'BBB', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)}
MYNEWVAR_3 = {countif( 'CCC', D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12)}

b) 1 equation to compare the results and display your messages.
{if(MYNEWVAR_1 > (MYNEWVAR_2 + MYNEWVAR_3), 'hello world!', 'bye bye' )}

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose