Survey is about hours spent per product. Products shown depends on chosen department. Department X has products UB1 and UB2, department Y has products UB3 and UB4. Defaults answer values are all set to 0.
User can only enter input for products of chosen department. So, if department Y is chosen the user will only be asked to enter hours spent on products UB3 and UB4, and cannot enter hours for UB1 nor UB2.
I want to create a single generic "total hours spent" formula, like total: {UB1+UB2+UB3+UB4}. This one failed. Apparently default values of hidden questions are NULL. That's fine.
Then I tried: total: {if(is_null(UB1,0,UB1)+if(is_null(UB2),0,UB2)+if(is_null(UB3),0,UB3)+if(is_null(UB4),0,UB4)}
This fails as well?? What should the general formula look like?
sum(UB1.NAOK,UB2.NAOK,UB3.NAOK,UB4.NAOK) seems the best
Note, for consistency between JavaScript and PHP, the plus operator (+) does addition if both operands are numeric, but does concatenation if both parts are non-numeric strings. However, we recommend using the join() function for concatenation, as that makes your intent more clear, and avoids unexpected results if you were expecting strings but got numbers instead (or vice versa).
I put a subtile to give the link more easy on forum
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
Last edit: 6 years 7 months ago by DenisChenu. Reason: quote