Welcome to the LimeSurvey Community Forum

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

Calculations on personality test with random questions

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #209534 by Joffm
Hi,

1. Sorry, small typo.
NOT count(Q01.NAOK), BUT count(that.Q01.NAOK)

2. Well, now you will get a huge amount of single equations.
For me it is not very clear, what you want to display to the respondents at the end of the survey.

Nevertheless: In my opinion better:
Create an array(numbers) (I called it "ArrNbr")
like this


and assign the calculated values to the cells.
Here you need only one equation where you insert all your formulas.
You see the "=" sign to assign the results to a cell of the array.


I only show the first two equations of each block to show the structure.

{ArrNbr_Q01_total=count(that.Q01)}
{ArrNbr_Q02_total=count(that.Q02)}
...

{ArrNbr_total_V=count(that.Q01.sq_V.NAOK,that.Q02.sq_V.NAOK,that.Q03.sq_V.NAOK,that.Q21.sq_V.NAOK,that.Q22.sq_V.NAOK,that.Q23.sq_V.NAOK)}
{ArrNbr_total_E=count(that.Q01.sq_E.NAOK,that.Q02.sq_E.NAOK,that.Q03.sq_E.NAOK,that.Q21.sq_E.NAOK,that.Q22.sq_E.NAOK,that.Q23.sq_E.NAOK)}
...

{ArrNbr_Q01_V=if(ArrNbr_total_V gt 0 and Q01_V=="Y",100/ArrNbr_total_V,0)}
{ArrNbr_Q02_V=if(ArrNbr_total_V gt 0 and Q02_V=="Y",100/ArrNbr_total_V,0)}
...
{ArrNbr_Q01_E=if(ArrNbr_total_E gt 0 and Q01_E=="Y",100/ArrNbr_total_E,0)}
{ArrNbr_Q02_E=if(ArrNbr_total_E gt 0 and Q02_E=="Y",100/ArrNbr_total_E,0)}
...
{ArrNbr_Q01_R=if(ArrNbr_total_R gt 0 and Q01_R=="Y",100/ArrNbr_total_R,0)}
{ArrNbr_Q02_R=if(ArrNbr_total_R gt 0 and Q02_R=="Y",100/ArrNbr_total_R,0)}
...

{ArrNbr_totScore_V=sum(if(ArrNbr_Q01_total gt 0 and Q01_V=="Y",100/ArrNbr_Q01_total,0),if(ArrNbr_Q02_total gt 0 and Q02_V=="Y",100/ArrNbr_Q02_total,0),if(ArrNbr_Q03_total gt 0 and Q03_V=="Y",100/ArrNbr_Q03_total,0),if(ArrNbr_Q21_total gt 0 and Q21_V=="Y",100/ArrNbr_Q21_total,0),if(ArrNbr_Q22_total gt 0 and Q22_V=="Y",100/ArrNbr_Q22_total,0),if(ArrNbr_Q23_total gt 0 and Q23_V=="Y",100/ArrNbr_Q23_total,0))}
{ArrNbr_totScore_E=sum(if(ArrNbr_Q01_total gt 0 and Q01_E=="Y",100/ArrNbr_Q01_total,0),if(ArrNbr_Q02_total gt 0 and Q02_E=="Y",100/ArrNbr_Q02_total,0),if(ArrNbr_Q03_total gt 0 and Q03_E=="Y",100/ArrNbr_Q03_total,0),if(ArrNbr_Q21_total gt 0 and Q21_E=="Y",100/ArrNbr_Q21_total,0),if(ArrNbr_Q22_total gt 0 and Q22_E=="Y",100/ArrNbr_Q22_total,0),if(ArrNbr_Q23_total gt 0 and Q23_E=="Y",100/ArrNbr_Q23_total,0))}
...

And you get this array


You do not save columns in the database, but a lot in your survey structure.
Only this


By the way:
{sum(if(and(Q01NbRep>0,Q01_A=="Y"),
This is wrong syntax. "and" is not a function, but an operator.
So it is
{sum(if(Q01NbRep>0 and Q01_A=="Y",

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ernahaka
  • ernahaka's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #209593 by ernahaka
thank you Joffm for taking time to answer in detail. As you may have noticed (haha) im a beginner at coding so i need some time to digest your recommendation. ill get back to you later about it.
have a nice day!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose