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

More
4 years 3 weeks ago #95738 by pksupport
pksupport created the topic: End message script I need to round a percentage down to two places
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.

Please Log in to join the conversation.

More
3 years 11 months ago #96857 by pksupport
pksupport replied the topic: End message script I need to round a percentage down to two places
:( 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?

Please Log in to join the conversation.

More
3 years 11 months ago #96873 by Ben_V
Ben_V replied the topic: End message script I need to round a percentage down to two places
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
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: pksupport

Please Log in to join the conversation.

More
3 years 11 months ago #96894 by pksupport
pksupport replied the topic: End message script I need to round a percentage down to two places
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)}

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now