Welcome to the LimeSurvey Community Forum

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

Quotas in numerical questions

  • Mon2016
  • Mon2016's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 years 6 months ago #222590 by Mon2016
Quotas in numerical questions was created by Mon2016
Hello to all the members of this beautiful forum. I hope all of you are okey.

I want to tell you that I am conducting a survey where various consumer brands are being asked.

I tell you a little:

I have a question with 30 brands where the question is

Q1. Which of these brands have you bought for your home? (multiple choice)

In the next question it is:

Q2. Now of the last 10 acts of purchase that you have made, indicate how many have been of each of these brands that you bought (Multiple Numbers)

Now my dilemma is that internally I must control these users of each brand, that is, I must take as a user that brand in which in Q2 it has given the highest number of purchases.

As an example, let's say you chose brand 1, 4, and 5 in Q1 as brands you frequently shop for.

and in Q2. of those 10 purchases he distributes them as follows:

Brand1 - 2
Brand2 - 3
Brand3 - 5

So I would take brand 3 as a brand user.

Now I realize that I cannot assign a quota to a numerical question to control my quotas by brand.


Is there an alternative to be able to carry out this mark control?

I would appreciate if you could guide me on how to do it.


Thank you all again for your valuable help. :)
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago - 3 years 6 months ago #222593 by Joffm
Replied by Joffm on topic Quotas in numerical questions
Hi,brand 
as far as I understand, you don't want to use  a quota but only select the brand with the highest value in Q2.

A rough idea:
Use two questions of type equation.
1. (eqMax) You calculte the highest given value with function "max" 
Like: {max(that.Q2.NAOK)}

2. (eqBrand) to select the brand with this max. value
Use a nested IF-Statement, like
{if(eqMax==Q2_SQ001,"Brand 1",if(eqMax==Q2_SQ002,"Brand 2",if(eqMax==Q2_SQ003,"Brand 3",if(eqMax==Q2_SQ004,"Brand 4",if(eqMax==Q2_SQ005,"Brand 5",if(eqMax==Q2_SQ006,"Brand 6",if(eqMax==Q2_SQ007,"Brand 7","Brand 8")))))))}
Adapt to your needs.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 6 months ago by Joffm.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #222596 by Joffm
Replied by Joffm on topic Quotas in numerical questions
Hi,
this first idea does not handle ties (same values).
If two brands have the max. value the function always selects the first.

If this is a problem for you you can expand this a little bit.
1. Calculate the max value
eqMax: {max(that.Q2.NAOK)}

2. Gather all brands with this value in a string
eqBrands: {join(if(Q2_SQ001==eqMax,"A",""),if(Q2_SQ002==eqMax,"B",""),if(Q2_SQ003==eqMax,"C",""),if(Q2_SQ004==eqMax,"D",""),if(Q2_SQ005==eqMax,"E",""),if(Q2_SQ006==eqMax,"F",""))}
You will get something like "BEF".

3. Generate a random number between 1 and the length of this string.
eqRand: {rand(1,strlen(eqBrands))}
You will get something like "2"

4. Extract the corresponding letter from the string.
eqBrand: {substr(eqBrands,eqRand-1,1)}
Now you have "E"

5. Store the selected brand
eqSelBrand: {if(eqBrand=="A","Brand A",if(eqBrand=="B","Brand B",if(eqBrand=="C","Brand C",if(eqBrand=="D","Brand D",if(eqBrand=="E","Brand E","Brand F")))))}

Now you can proceed in your survey; the selected brand is stored in "eqSelBrand".

Here shown for 6 brands. You have to adapt to your needs.
By the way: If you have 30 different brands, the capital letters are not enough. Use others (small letters, digits). 

Here a sample, created in LS version 3.27.19.
 

File Attachment:

File Name: limesurvey...9396.lss
File Size:28 KB


This all without javascript, only with built-in functions, which you see in the manual:
[url] www.limesurvey.org/manual/ExpressionScri...mplemented_functions [/url]

And as I said before:
If I misunderstood your requirement, please explain.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #222597 by tpartner
Replied by tpartner on topic Quotas in numerical questions
What if several brands have the same "max" number?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago - 3 years 6 months ago #222599 by Joffm
Replied by Joffm on topic Quotas in numerical questions

What if several brands have the same "max" number?

The expanded version covers this.

Therefore I wrote in my first post "A rough idea".
I had no more time this morning.

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 6 months ago by Joffm.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose