Hi,
as promised the explanation of this equation
{sum(that.AQ.sq_N.valueNAOK,(count(that.AQ.sq_R)-sum(that.AQ.sq_R.valueNAOK)))}
But first let's see how to handle the "reverse" items.
In your case the assessment value "1" has to be converted to "0" and "0" has to be converted to "1".
You do this by subtracting the value from 1:
If the value is 1: 1 - 1 = 0
If the value is 0: 1 - 0 = 1
Now the rough equation to calculate the score would be
{AQ_SQ001.valueNAOK+(1-AQ_SQ002.valueNAOK)+(1-AQ_SQ003.valueNAOK)+(1-AQ_SQ004.valueNAOK)+(1-AQ_SQ005.valueNAOK)+(1-AQ_SQ006.valueNAOK)+AQ_SQ007.valueNAOK+AQ_SQ008.valueNAOK+(1-AQ_SQ009.valueNAOK)+AQ_SQ010.valueNAOK}
To make the whole explanation shorter I replace
AQ_SQ001.valueNAOK by x1
AQ_SQ002.valueNAOK by x2
...
So it is
x1+(1-x2)+(1-x3)+(1-x4)+(1-x5)+(1-x6)+x7+x8+(1-x9)+x10
Let's order a bit
x1+x7+x8+x10+(1-x2)+(1-x3)+(1-x4)+(1-x5)+(1-x6)+(1-x9)
But this is equal to
x1+x7+x8+x10+1+1+1+1+1+1-x2-x3-x4-x5-x6-x9
Equal
x1+x7+x8+x10+1+1+1+1+1+1-(x2+x3+x4+x5+x6+x9)
Equal
x1+x7+x8+x10 + 6 - (x2+x3+x4+x5+x6+x9)
Now there is
x1+x7+x8+x10 : The sum of the values of "normal" items
6: To convert the value we subtract from 1, and we do it for each "reverse" subquestion. So here it is just the number of subquestions with "reverse" items, count(x2,x3,x4,x5,x6,x9)
x2+x3+x4+x5+x6+x9: The sum of the values of "reverse" items
Till now it is simple arithmetic.
Shorter:
sum(x1,x7,x8,x10),(count(x2,x3,x4,x5,x6,x9) - sum(x2,x3,x4,x5,x6,x9)))
If we now replace the x1,x2,... by the original AQ_SQ001,...
sum(AQ_SQ001.valueNAOK,AQ_SQ007.valueNAOK,AQ_SQ008.valueNAOK,AQ_SQ010.valueNAOK),(count(AQ_SQ00",AQ_SQ003,AQ_SQ004,AQ_SQ005,AQ_SQ006,AQ_SQ009) - sum(AQ_SQ002.valueNAOK,AQ_SQ003.valueNAOK,AQ_SQ004.valueNAOK,AQ_SQ005.valueNAOK,AQ_SQ006.valueNAOK,AQ_SQ009.valueNAOK)))
That's fine.
But let's make this formula independent from the total number of items, from the number of "reverse" items - a general solution.
We do the trick with the "that" Variable.
Example:
What does "{sum(AQ.sq_X)}" mean.
You see it when you enter this in your question text and save the question.
It is expanded to
{sum(AQ_X001,AQ_X002,AQ_X003,AQ_X004,...)}
to all subquestions where the code contains an "X"
Therefore I advised to code the "normal" items "N01", "N02",... and the "reverse" items "R01", "R02",... - to distinguish between "normal" items and "reverse" items.
Then we can write the equation as
sum(AQ_N01.valueNAOK,AQ_N07.valueNAOK,AQ_N08.valueNAOK,AQ_N10.valueNAOK),(count(AQ_R02,AQ_R03,AQ_R04,AQ_R05,AQ_R06,AQ_R09) - sum(AQ_R02.valueNAOK,AQ_R03.valueNAOK,AQ_R04.valueNAOK,AQ_R05.valueNAOK,AQ_R06.valueNAOK,AQ_R09.valueNAOK)))
And using "that" it is only:
sum(that.AQ.sq_N.valueNAOK),(count(that.AQ.sq_R) - sum(that.AQ.sq_R.valueNAOK)))
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless