Welcome to the LimeSurvey Community Forum

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

Exclusive codes when randomizing

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250841 by Mon2016
Exclusive codes when randomizing was created by Mon2016
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)

Hello dear group,

I am making a shelf-type presentation where I show 33 products and the respondent must mark how many units of each product they would buy in the last 30 days, this in two versions with 14 scenarios that are shown depending on the rotation.

After (in Q13) this shelving exercise, I asked if the products you selected in this exercise told you that there was no longer what product you would replace it with. and I randomly take 6 of these products that you have selected.

So far so good since I used "countifop" to count those that have been selected in one of the scenarios and to be able to calculate this count.

tArray_1=countifop(">", "", Q2V1T01_1.NAOK, Q2V1T02_1.NAOK, Q2V1T03_1.NAOK, Q2V1T04_1.NAOK, Q2V1T05_1.NAOK, Q2V1T06_1.NAOK, Q2V1T07_1.NAOK, Q2V1T08_1.NAOK, Q2V 1T09_1.NAOK, Q2V1T10_1.NAOK , Q2V1T11_1.NAOK, Q2V1T12_1.NAOK, Q2V1T13_1.NAOK, Q2V1T14_1.NAOK, Q2V2T01_1.NAOK, Q2V2T02_1.NAOK, Q2V2T03_1.NAOK, Q2V2T04_1.NAOK, Q2V2T05_1.NAOK, Q2V 2T06_1.NAOK, Q2V2T07_1.NAOK, Q2V2T08_1.NAOK, Q2V2T09_1 .NAOK, Q2V2T10_1.NAOK, Q2V2T11_1.NAOK, Q2V2T12_1.NAOK, Q2V2T13_1.NAOK, Q2V2T14_1.NAOK)


But my problem is that I have 5 product innovations that I need to give priority to, that is... codes 5, 7, 8, 13 and 15 must be a priority if they are selected in any of the exercises.

If you selected the codes

12
twenty
7
fifteen
25
30
28
twenty

I must show only 6 randomly but always giving priority to the codes that I mentioned, in this case I must show code 7 and 15 and the remaining 4 randomly.

I hope I have been a little clear, my English is not very good.

I leave you an export in the lss of my survey. mi versión  Versión 3.25.10+210128

Greetings all.

Please Log in to join the conversation.

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250850 by Mon2016
Replied by Mon2016 on topic Exclusive codes when randomizing
Hello

I was playing around a bit and did this with l expression to prioritize my 5 codes that I'm looking for:

{if(tArray_5>0 and tArray_7>0 and tArray_8>0 and tArray_13>0 and tArray_15>0, join(if(tArray_5>0,"E",""),if(tArray_7>0,"G",""),if(tArray_8>0,"H",""),if(tArray_13>0,"M",""),if(tArray_15>0,"O","")),join(if(tArray_1>0,"A",""),if(tArray_2>0,"B",""),if(tArray_3>0,"C",""),if(tArray_4>0,"D",""),if(tArray_6>0,"F",""),if(tArray_9>0,"I",""),if(tArray_10>0,"J",""),if(tArray_11>0,"K",""),if(tArray_12>0,"L",""),if(tArray_14>0,"N",""),if(tArray_16>0,"P",""),if(tArray_17>0,"Q",""),if(tArray_18>0,"R",""),if(tArray_19>0,"S",""),if(tArray_20>0,"T",""),if(tArray_21>0,"U",""),if(tArray_22>0,"V",""),if(tArray_23>0,"W",""),if(tArray_24>0,"X",""),if(tArray_25>0,"Y",""),if(tArray_26>0,"Z",""),if(tArray_27>0,"1",""),if(tArray_28>0,"2",""),if(tArray_29>0,"3",""),if(tArray_30>0,"4",""),if(tArray_31>0,"5",""),if(tArray_32>0,"6",""),if(tArray_33>0,"7","")))}


And if it does it to me, however, this means that if I enter several codes including these 5, it only calculates the 5.

What I'm really looking for is to ask for 6 products, giving priority to the 5 codes. If you selected 2 codes, we first ask those 2 and another 4 additional ones that are not priority.

If you did not select any of the codes in any of the 14 scenarios, then their substitutes are applied to 6 products.


I hope if anyone has any other ideas.


Greetings,

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 3 weeks ago #250855 by Joffm
Replied by Joffm on topic Exclusive codes when randomizing
Hi,
1.
if(count(that.Q2V1T01.NAOK,that.Q3V1T01.NAOK, that.Q4V1T01.NAOK, that.Q5V1T01.NAOK,that.Q6V1T01.NAOK,that.Q7V1T01.NAOK)>0,Q8V1T01_1.NAOK!="Y",Q8V1T01_1.NAOK=="Y")
This is not a correct validation equation. What do you try to achieve?

2. In the relevance equation of P1301 ff. there is a reference to Q2V3Txx, what is not existing in your lss.

Now to your last idea.
What for do you use the first IF?
Now the string is only created if one of the priority brands is selected. Remove it and
1. the very easy solution
create the string as:
{join(if(tArray_5>0,"E",""),if(tArray_7>0,"G",""),... ( the priority brands)
as you did already.
To get a randomization of the other brands you may use 4 different orders of joining.
Like:
1. Priority brands, other brands in ascending order
2. Priority brands, other brands in descending order
3. Priority brands, other brands in other orders (16,15,14,...,32,31,30,...)
4. Priority brands, other brands in other orders (17,18,19,...,1,2,3,3,...)
Whatever you like.
And with a random number you select the function.
In my opinion this is sufficient to get the other brands randomly.

The way to do it exactly with some equations is described several times here.

Or you use a question of type "multiple short text"
In the first subquestion you enter the joined string of priority brands ("CH")
In the second the string of the other brands.("BLRSUVZ5"
Both you can do by "default answers".
With javascript in this question shuffle the second string and join the first and the second.
So you may getyour 6 final brands as "CHZ5LU"
Later I will create a sample survey; but only a prototype to show the way.

Joffm
 

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

Please Log in to join the conversation.

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250867 by Mon2016
Replied by Mon2016 on topic Exclusive codes when randomizing
Hello joffm

Thanks for your answer.

In theory I was looking for a way to do it and it was like my option in expression.

You are right, the lss survey I shared had that error with the reference of variables that do not exist. (I share a complete survey of what I did for further reference)

I want to be honest and tell you that I didn't understand very well how to separate the priority brands as you mention,

I think it took me a bit of work to understand it, I don't know if it bothers me much that you helped me understand it better. :)


Thank you very much joffmm 

Please Log in to join the conversation.

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250868 by Mon2016
Replied by Mon2016 on topic Exclusive codes when randomizing
Forgot to share the lss

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 3 weeks ago #250886 by Joffm
Replied by Joffm on topic Exclusive codes when randomizing
Hi,
here the promised prototype with less brands. But it shows the way.
The first two solutions I mentioned before.
I can't provide the javascript solution because I am on holiday.

Joffm

 

File Attachment:

File Name: limesurvey...6427.lss
File Size:38 KB

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 3 weeks ago #250891 by Joffm
Replied by Joffm on topic Exclusive codes when randomizing
Here with added javascript solution
 

File Attachment:

File Name: limesurvey...0-03.lss
File Size:43 KB


Joffm

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

Please Log in to join the conversation.

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250896 by Mon2016
Replied by Mon2016 on topic Exclusive codes when randomizing
Thank you very much, joffm

I used the 3 options and everything was fine, only in the Java option I see that it used the css: hidden to hide, but this only hides the text/information on the screen and leaves me with a blank variable and I must say "next" " to move forward,

I know maybe the "Hide this question" option can make the script not work, how could I hide without hiding? jajaja

Thanks for your great help.

Please Log in to join the conversation.

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago #250898 by Mon2016
Replied by Mon2016 on topic Exclusive codes when randomizing
Hello joffm

I already solved it, I attached a text display question in the same group of the equation where I explain the next section that comes and left the "hidden" .

Thank you very much Joffm for all your help. 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 3 weeks ago #250910 by Joffm
Replied by Joffm on topic Exclusive codes when randomizing
In the script there is an instruction to trigger the "next" button.
Of course it depends on your way to display your questions.

Joffm 

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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose