Welcome to the LimeSurvey Community Forum

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

Can I find the first 3 options in the Array (Numbers) question and then use them

  • FreshLemonUser
  • FreshLemonUser's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 11 months ago - 1 year 11 months ago #228541 by FreshLemonUser
LimeSurvey version: LimeSurvey Community Edition Versión 5.3.5
Own server : 
Survey theme/template: Bootswatch
==================

Hi all, I would like to get help with the following:

I have a question that is an array of numbers and I need to pull the Top 3 from the top of the array. 

Subsequently I need to take the labels of the 3 options with the highest value (Top 3) and Place them as the header of another text array. 

How can I do this? 

I have not been able to do it

This image shows my need:

 

I tried to follow some of the suggestions in these two posts but could not replicate them:

forums.limesurvey.org/forum/can-i-do-thi...ray-numbers-question

forums.limesurvey.org/forum/design-issue...iption-by-top-ranked

Please find attached the test survey.:

 

File Attachment:

File Name: teste_top_n_array.lss
File Size:36 KB


Thank you very much in advance.
Last edit: 1 year 11 months ago by FreshLemonUser.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228566 by Joffm
Here a solution with only a few equations.
There is no full handling of ties.

1. eqMax1: Calculate the maximum of all values
2. eqB1: Join some representatives "A", "B", "C", with this value
3. eqMax2: Calculate the maximum of all values less then the first maximum
4. eqB2: Join some representatives "A", "B", "C", with this value
5. eqMax3: Calculate the maximum of all values less then the second maximum
6. eqB3: Join some representatives "A", "B", "C", with this value
7. eqResult: Join eqB1, eqB2, eqB3 and take the first three characters

Now there are two ways to display
1. Your idea:
1st Column: If the first character is "A", it is "case 1", else if the first character is "B", it is "case 2", and so on
{if(substr(eqResult,0,1)=="A","case 1",if(substr(eqResult,0,1)=="B","case 2",if(substr(eqResult,0,1)=="C","case 3",if(substr(eqResult,0,1)=="D","case 4","case 5"))))}
2nd colum: Use the second character of the string in eqResult "substr(eqResult,1,1)"
As you do not know which case will be in which column your analysis will be really hard. You will have to restructure your dataset that you get case 1 in clumn 1, case 2 in column 2, ...
This is shown here
 

File Attachment:

File Name: limesurvey...4573.lss
File Size:63 KB



2. Use the plugin "hideEmptycolumn"
[url] gitlab.com/SondagesPro/QuestionSettingsType/hideEmptyColumn [/url]
Create five columns in Q32 "case1", "case 2", "case 3", ...
Use this as x-scale subquestions
{if(strpos("#"+eqResult,"A")>0,"case 1","")}
{if(strpos("#"+eqResult,"B")>0,"case 2","")}

{if(strpos("#"+eqResult,"C")>0,"case 3","")}
...
Meaning: if eqResult contains "A" the column has a value ("case 1"). Otherwise it is empty - and is not displayed.
This hashtag at the start is used to get a minimum index of 1, as an index of "0" means "not found" - and "strpos" starts counting at "0".

This way you will get a well structured dataset.

​​​​​​​Joffm

 

 

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

Please Log in to join the conversation.

  • FreshLemonUser
  • FreshLemonUser's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 10 months ago - 1 year 10 months ago #228598 by FreshLemonUser
Dear Joffm, I want to thank you for your support, you really saved my day.

The two solutions work perfectly, the first option as you shared it in the survey file works great.

The second option using the plugin "hideEmptycolumn" from gitlab.com/SondagesPro/QuestionSettingsType/hideEmptyColumn also works very well.

Regarding the second option, you are quite right, it is better because my data will be organized, therefore, I will take the second option. Using the plugin, creating the 5 corresponding columns, this way the data will be organized.

Finally and for practical purposes, speaking of visualization, can the order of presentation of the columns be organized when using method 2?

I mean in this example case the order is according to answers given on Q31: case 3 = 50 , case 5 = 30 , case 2 = 10.

Method 1: Displayed in descending order, but my data will be very difficult to analyze,

Method 2: when using the plugin the 3 columns with the highest rating are displayed correctly but in native order of the columns, in this case, it would be very useful if the columns could be displayed in descending order. 

 

Thanks again

Best regards!!!
Last edit: 1 year 10 months ago by FreshLemonUser.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #228613 by Joffm
Hi,

in this case, it would be very useful if the columns could be displayed in descending order. 

and sometimes I want to answer "and I would like to have a Ferrari" 

To be honest:
1. There might be a way to do this with javascript.
But I think the whole approach has to be changed.
And this is far beyond my abilities concerning javascript. I am good at equations.

2. The restructuring of the dataset is really easy done with a small macro in Excel

Joffm
 

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

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #228619 by holch

and sometimes I want to answer "and I would like to have a Ferrari" File Attachment:


Do you, Joffm? Do you really want to try and get in and out of a Ferrari? ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #228625 by Joffm
Oh, holch, you are right.
Sometimes I forget my age.

But what about a convertible? Could be easier.

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • FreshLemonUser
  • FreshLemonUser's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 10 months ago #228626 by FreshLemonUser
Hello dear Joffm, 

Please let me join your Ferrari Club, "I also want to have a Ferrari." 

On the other hand, I would like to thank you again, your solutions work quite well, they are just perfect,  and you are absolutely right I can organize my data set later .

For now I will keep working as hard as I can to join your club.

Regards

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
1 year 10 months ago #228628 by tammo


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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose