Rank Array Totals & Provide Description by Top Ranked

More
4 years 3 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:

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
4 years 3 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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 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?

Please Log in or Create an account to join the conversation.

More
4 years 3 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:
manual.limesurvey.org/Expression_Manager#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).

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 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.
Attachments:

Please Log in or Create an account to join the conversation.

More
4 years 3 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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 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:
manual.limesurvey.org/Expression_Manager_Examples

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 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?
Attachments:

Please Log in or Create an account to join the conversation.

More
4 years 3 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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago - 4 years 3 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: 4 years 3 months ago by ccapra.

Please Log in or Create an account to join the conversation.

More
4 years 3 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?

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago - 4 years 3 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:
{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".
{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):
{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.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 4 years 3 months ago by tpartner.

Please Log in or Create an account to join the conversation.

More
4 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'?

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #120359 by tpartner
Well, there may be a more elegant way but you could simply extend the nested IFs:
{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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!