Welcome to the LimeSurvey Community Forum

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

Round up number to nearest multiple of 5 with Expression Manager Functions (LS3)

More
3 years 10 months ago #218770 by Qsgt
I have a numerical value stored in a multiple numerical input question and I want to round the value to the nearest multiple of 5 using the expression manager. I want to use implementation 3 like in this StackOverflow question  but it uses the modulo operator which LS3 does not support. How can I replicate this using the expression manager in LS3?

Thanks in advance,
qsgt
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #218771 by tpartner
Do you want to round up or simply round?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
3 years 10 months ago #218772 by Qsgt
Hi,

I'd like to round up if the number is not already a multiple of five. i.e. 50 should stay at 50, 55 should stay 55 and 60 should stay 60. But, any number between 50.1 and 54.9 should round to 55 and any number between 55.1 and 59.9 should round to 60.

Is this possible?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago - 3 years 10 months ago #218774 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 10 months ago by tpartner.
The following user(s) said Thank You: Qsgt
The topic has been locked.
More
3 years 10 months ago #218780 by Qsgt
That’s perfect! Thanks very much.

qsgt
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose