Welcome to the LimeSurvey Community Forum

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

Expression script: Find the questioncode with the highest score

  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
1 month 3 weeks ago - 1 month 3 weeks ago #270670 by tammo
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.13.1
Own server or LimeSurvey hosting: Own
Survey theme/template: not relevant
==================
In 5 questions, let's call them: sc01, sc02, sc03, sc04 and sc05 I compute scores between 1 - 10 of some previous questions.

Scenario:
sc01 = 5
sc02 = 3
sc03 = 1
sc04 = 6
sc05 = 6

I would like to know which of the 5 question codes scores highest (in this case sc04 AND sc05, so the first is chosen)
This should lead to the following scores:
sc06 = sc04
sc07 = 1 (because there are multiple highest scores, if there is only 1, this should be 0)

I cannot find out how to do this, Any help is appreciated.

Tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Last edit: 1 month 3 weeks ago by tammo.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 3 weeks ago #270671 by Joffm
Hi, tammo,
I usually do it like this with these two equations.
Here I used "list(radio)" to enter the scores. With "numeric" questions or "equations" it's analogue.
 
1. Calculate the maximum (eqMax)
{max(sc1.NAOK,sc2.NAOK,sc3.NAOK,sc4.NAOK,sc5.NAOK)}
2. Set sc6 and sc7 (eqSet)
{sc6=if(sc1==eqMax,1,if(sc2==eqMax,2,if(sc3==eqMax,3,if(sc4==eqMax,4,5))))}
{sc7=if(countif(eqMax,sc1,sc2,sc3,sc4,sc5)>1,1,0)}





with sc6 as
 

Or do you want to display sc6 in a different manner?

Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tammo

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
1 month 3 weeks ago #270672 by tammo
Great, geweldig!

This works, thank you!

I could find out the first expression, but the one with "countif" was unknown to me!

Tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose