Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: End message script I need to round a percentage down to two places

End message script I need to round a percentage down to two places 3 years 2 months ago #95738

  • pksupport
  • pksupport's Avatar
  • Offline
  • Senior Lime
  • Posts: 46
  • Thank you received: 1
  • Karma: 0
How can I limit a number to 2 decimal places in this code:

Your percentage for Knowledge and skills was:{sum(that.A01.value, that.A06.value, that.A07.value, that.A08.value, that.A12.value, that.A15.value) / 60 * 100} %

Thanks for your time - it's much appreciated.
The administrator has disabled public write access.

End message script I need to round a percentage down to two places 3 years 1 month ago #96857

  • pksupport
  • pksupport's Avatar
  • Offline
  • Senior Lime
  • Posts: 46
  • Thank you received: 1
  • Karma: 0
:( Please!! I have been working hard on this. I can use {floor} but I can't get this to work as I have posted and I need it! Can I pay someone?
The administrator has disabled public write access.

End message script I need to round a percentage down to two places 3 years 1 month ago #96873

  • Ben_V
  • Ben_V's Avatar
  • Offline
  • Platinum Lime
  • Posts: 1798
  • Thank you received: 440
  • Karma: 110
Not tried, but probably something like this:
{round(sum(that.A01.value, that.A06.value, that.A07.value, that.A08.value, that.A12.value, that.A15.value) / 60 * 100),2}
Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
All LS releases => bit.ly/1VMuTDu | 2.06lts => bit.ly/1Qv44A1
Demo surveys => bit.ly/20NW9V8 (already included in /docs/demosurveys)
The administrator has disabled public write access.
The following user(s) said Thank You: pksupport

End message script I need to round a percentage down to two places 3 years 1 month ago #96894

  • pksupport
  • pksupport's Avatar
  • Offline
  • Senior Lime
  • Posts: 46
  • Thank you received: 1
  • Karma: 0
THANK YOU!! :cheer:

{round(sum(that.A01.value, that.A06.value, that.A07.value, that.A08.value, that.A12.value, that.A15.value) / 60 * 100),2}

I took off the 2 at the end - was this places? It works. Very very happy as I spent a lot of time on this, so again, thank you very much.

Solution to round down a summed value:

{round(sum(that.A01.value, that.A06.value, that.A07.value, that.A08.value, that.A12.value, that.A15.value) / 60 * 100)}
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.201 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form