Welcome to the LimeSurvey Community Forum

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

Rank Array Totals & Provide Description by Top Ranked

More
10 years 4 months ago #120191 by ccapra
I also asked this in the IRC Live Chat - is it uncool to ask in both places?

I have a survey with 4 question groups - each group has one Array question. Assessments are turned on. There are 8-11 subquestions in each array. Each sub-question in the array has 3 response options, the response options have values 0, 1, & 2.

I want to total the response values for each array, then rank the groups by those sums, and give a written summary depending on which group had the highest total. How do I do that?

:unsure:
The topic has been locked.
More
10 years 4 months ago #120192 by holch
You will need to learn how use the expression manager. If you look at the manual, it gives you a few examples on what you can do with the expression manager. You can create your own reports using text display questions.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago #120193 by holch
You will need to learn how use the expression manager. If you look at the manual, it gives you a few examples on what you can do with the expression manager. You can create your own reports using text display questions.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago #120194 by ccapra
Thanks @holch,

And I need more detail,

I have read the manual about Expression Manager - it's fairly sketchy.

From what I can tell, I need to use an equation for each group total - but I can't quite tell how to write that.

If my group array question is A1, and the responses are sq001-sq0011, how would I write the equation? And where would the result end up?

Then, if I do that in an equation question for each array, where & how would I create the ranking function?
The topic has been locked.
More
10 years 4 months ago #120195 by holch
The expression manager manual isn't something you read in a few minutes and understand it. At the beginning it looks quite complicated, but once you tried some of the examples, you'll get a hang for it.

Well, you need to check how you can access the assements, which is explained here:
www.limesurvey.org/manual/Expression_Man...#Access_to_Variables

I would say it is something like A1_sq001.value.

So you might have to do something like this {resultA1 = A1_sq001.value + A1_sq002.value +...+ A1_sq011.value}

So resultA1 should have a sum of all assment values from sq001 to sq011 (of course you need to add the missing subquestions were "..." is).

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago #120196 by ccapra
When does that function run? i.e. when does the result show?

I'm just trying to figure out if I'm understanding the equation correctly, so I put {A1_SQ001.value}
I did activate the survey.

What I get is in the attached screenshot. I also attached a shot of the logic file for that question group as well.
The topic has been locked.
More
10 years 4 months ago #120198 by holch
If you just want to show the value, you need to put {A1_SQ001.value}. I think "resultA1 = A1_sq001.value" will only work if you put it within {} and probably only in an equation type question.

If you just want to show the result for A1_SQ001, then you put {A1_SQ001.value} and it should show either 0, 1 or 2, depending on the question chosen.

The red highlight shows that there is a problem with "resultA1", because it is not allowed where you used it, I guess.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago #120199 by holch
Here you can find some examples on how to use expression manager, which will help to understand how it works:
www.limesurvey.org/manual/Expression_Manager_Examples

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago #120201 by ccapra
Ok, thanks. Making progress!

I inserted just {A1_SQ001.value} in the equation & that worked - so at least I'm on the right track:-)

So then I put in {resultA1 = A1_SQ001.value + A1_SQ002.value} based on your previous note (Just to test I'm doing it right before I write it all out for all the SQs.

But that doesn't work. Again I get an error message on the logic file - attached.

Can you see what I did wrong there?
The topic has been locked.
More
10 years 4 months ago #120207 by holch
Well, I am not 100% sure if this resultA1 = part works. What you could try is just put the sum part. That should give you the value of the sum, you just don't have a variable. But later you can use the question code of this equation question to calculate the sum of the various questions that you have.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 months ago - 10 years 4 months ago #120254 by ccapra
Ok - so I used this {(A1_SQ001.value + A1_SQ002.value)} & it worked.

So now my question is, is there a way to rank the four results.

Say
A1_SQ001-SQ0011 (i.e. Q1) = 15
A2_SQ001-SQ0011 (i.e. Q2) = 28
A3_SQ001-SQ0011 (i.e. Q3) = 22
A4_SQ001-SQ0011 (i.e. Q4) = 31


I want to know which Q scored highest & say if Q-1 was highest show ...[description text], if Q-2 is highest show .... and so on. Is this possible? & how?
Last edit: 10 years 4 months ago by ccapra.
The topic has been locked.
More
10 years 4 months ago #120266 by ccapra
OK - I ran into an issue & started a new topic #120264.

www.limesurvey.org/en/forum/design-issues/100307-equation-issue

But I still want to know how to rank the results of the 4 arrays & deliver a different text output depending on the highest storing section.

Can anyone help with that?
The topic has been locked.
More
10 years 4 months ago - 10 years 4 months ago #120272 by tpartner

But I still want to know how to rank the results of the 4 arrays & deliver a different text output depending on the highest storing section.


Assumptions:
- 4 Arrays with question codes q1, q2, q3 and q4
- You do not expect any of the array assessment totals to equal another array assessment total

This will give you the "total assessment value" for an array, question code q1:
Code:
{sum(that.q1.value)}

So, then you could create a new "Equation" type question (let's call it "maxVal") with the following equation. This will give the highest "total assessment value".
Code:
{max(sum(that.q1.value), sum(that.q2.value), sum(that.q3.value), sum(that.q4.value))}

Then you can use nested IFs to display variable text depending on which array matches the highest "total assessment value" (line-breaks inserted for clarity):
Code:
{if(q1 == maxVal, 'Text if q1 highest', 
  if(q2 == maxVal, 'Text if q2 highest', 
    if(q3 == maxVal, 'Text if q3 highest', 
      if(q4 == maxVal, 'Text if q4 highest', 
        '' 
))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 4 months ago by tpartner.
The topic has been locked.
More
10 years 3 months ago #120354 by ccapra
Thanks! That all works beautifully!

So now, if there are two max scores, is there a way to give text for both? Like 'you are equally suited to Q1 and Q4' then 'text if q1' and 'text if q2'?
The topic has been locked.
More
10 years 3 months ago #120359 by tpartner
Well, there may be a more elegant way but you could simply extend the nested IFs:
Code:
{if(q1 == maxVal, 'Text if q1 highest', 
  if(q2 == maxVal, 'Text if q2 highest', 
    if(q3 == maxVal, 'Text if q3 highest', 
      if(q4 == maxVal, 'Text if q4 highest', 
        if(q1 == maxVal AND q2 == maxVal, 'You are equally suited to Q1 and Q2', 
          if(q1 == maxVal AND q3 == maxVal, 'You are equally suited to Q1 and Q3', 
            if(q1 == maxVal AND q4 == maxVal, 'You are equally suited to Q1 and Q4', 
              if(q2 == maxVal AND q3 == maxVal, 'You are equally suited to Q2 and Q3', 
                if(q2 == maxVal AND q4 == maxVal, 'You are equally suited to Q2 and Q4', 
                  if(q3 == maxVal AND q4 == maxVal, 'You are equally suited to Q3 and Q4', 
                    ''
))))))))))}

Or, perhaps several of those nested statements?


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose