Welcome to the LimeSurvey Community Forum

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

Identify identical values (arrays)

  • pmeiners
  • pmeiners's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago #192627 by pmeiners
Identify identical values (arrays) was created by pmeiners
Hello,
basically my question continues from this thread: www.limesurvey.org/de/foren/can-i-do-thi...d-name-that-have-max

I have several sliders for the same question and I want to collect information about which options were rated the highest and which the lowest.
So far, so good.
But in addition I want to choose one option, when several options are rated identically.

Therefore I need to identify which options are rated the highest and then choose randomly among them (and the same for the lowest rating).

How exactly could I accomplish this?

Thank you very much for your help!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #192628 by Joffm
Replied by Joffm on topic Identify identical values (arrays)
Hi,
in the other thread you saw how you calculate the min value and max value.
Unfortunately LimeSurvey does not support dynamic lists.
So you have to fake this.

A. max.
1. calculate the max value - like
maxValue: {max(that.Q1)}
2. create a string joining all companies with this max value - like
maxString: {join(if(Q1_SQ001==maxValue,"A",""),if(Q1_SQ002==maxValue,"B",""),if(Q1_SQ003==maxValue,"C",""), ...
If the second and the fifth company both have the maxvalue, you may have a string like "BE".
3. create a random number (1- length of the string) and grab the substr - like
maxCompany: {substr(maxString,rand(1,strlen(maxString))-1,1)} (-1, because the first index of substr is "0")

Now you have a random company (the related character) that was rated max.
This you may use for further calculations like relevance or assignments.

B. Min
analogue

Working example (only max)

File Attachment:

File Name: limesurvey...4292.lss
File Size:23 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner, pmeiners
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #192629 by tpartner
Replied by tpartner on topic Identify identical values (arrays)
I think Joffm now dreams in Expression Manager syntax. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • pmeiners
  • pmeiners's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago #192633 by pmeiners
Replied by pmeiners on topic Identify identical values (arrays)
Thanks, that works great!
The topic has been locked.
  • pmeiners
  • pmeiners's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #195534 by pmeiners
Replied by pmeiners on topic Identify identical values (arrays)
Is there also a way to check if the randomization process resulted in two identical results? Basically, can I force the entire statement to repeat if the results from MaxCompany and MinCompany end up identical?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #195570 by Joffm
Replied by Joffm on topic Identify identical values (arrays)
No,
but you could exclude the chosen MinCompany of the process selecting MaxCompany.
Here:
2. create a string joining all companies with this max value - like
maxString: {join(if(Q1_SQ001==maxValue,"A",""),if(Q1_SQ002==maxValue,"B",""),if(Q1_SQ003==maxValue,"C",""), ...
Extend the if-statement
{join(if(Q1_SQ001==maxValue AND minCompany!="A","A",""),if...

Or you validate the question that not all companies have the same rating.
So you avoid minCompany=maxCompany.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: pmeiners
The topic has been locked.
  • pmeiners
  • pmeiners's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #195731 by pmeiners
Replied by pmeiners on topic Identify identical values (arrays)
That is a good solution, thanks a lot for your help.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose