PDF Form Percentage calculation...

Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

I have a script to get the Percentage calculation, but i have to put a space before the percentage symbol as required by french translation eg. (100 %). I could not find it in the forms properties. Is there a way to get it in the script?

if (this.getField("Total").value != "") {

event.value = (this.getField("YOU SAVE").value /

this.getField("Total"). value)

}

TOPICS
Macintosh, PDF forms

Views

4.8K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Feb 28, 2018 Feb 28, 2018
event.value = Math.round((this.getField("YOU SAVE").value / this.getField("Total"). value)*100);

Likes

Translate

Translate
Most Valuable Participant ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

As the Format setting select Custom and then enter:

if (event.value) event.value += " %";

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

That works great, but without decimal places

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

What do you mean?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

This is what i'm getting: 93.33333333333 %.

I need it to look like this: 93 %

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

OK, that's not really related to the percentage symbol.

To do that change your calculation script to:

event.value = Math.round(this.getField("YOU SAVE").value / this.getField("Total"). value);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

Hi, sorry to keep bothering you. It's not working like the english version. See attached.Screen Shot 2018-02-28 at 4.05.53 PM.pngScreen Shot 2018-02-28 at 4.06.03 PM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

Multiply the result by 100 before rounding it...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

How would i do that?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

event.value = Math.round((this.getField("YOU SAVE").value / this.getField("Total"). value)*100);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

That's AWESOME!! Thanks so much for your help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

I am tried the formula but it would not work.  I am trying to get the Margin of Sales in Percent (Margin7/Rev1). 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Elaborate what you did and what the results were.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

I tried to divide my Projected Margin by Projected Revenue to get the percentage that mirrors my Excel file (Projected Margin in Percent).  It would not let me do the calculation on the Acrobat:

Melissa Reed

[Moderator note: personal information removed due to policies for this public forum.]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Your descriptions are very vague... How did you try it, exactly? Did you use a script? If so, post the code. If not, then how?

And what does "it would not let me do it" means? Was there an error message of some kind? If so, what did it say? etc.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

The formula I used in Field Percent8: ( Margin7/Rev1)*100.  The error message is “The value entered does not match the format of the field [Percent8}

Melissa

[Private information removed. - Mod.]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

OK, that's better (although you should not reply by email if contains your personal information).

This is happening because you're dividing by zero. To avoid it use this code as the custom calculation script:

var v1 = Number(this.getField("Margin7").valueAsString);

var v2 = Number(this.getField("Rev1").valueAsString);

if (v2==0) event.value = "";

else event.value = (v1/v2) * 100;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

ALMOST worked!  It gave me (based on $80/$100) 8000%.  How do I modify to get to 80%?

Melissa

[Moderator Note: Personal information removed. Please delete email signatures before responding to forum posts via email.]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Drop the multiplication by 100...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Thank you so much!!

Melissa Reed

[Moderator: Personal information removed]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

Hi, I have applied this calculation with success. So thank you for that! Do you happen to know also what to fill in if I want to get the percentage increase (or decrease)? For example in my form I will have a total for 2018 and a total for 2019 - I want to get the difference between the two totals but in percentage. I have added the % sign just as text next to the box to avoid that formating trouble. When using the format above (event.value = Math.round((this.getField("YOU SAVE").value / this.getField("Total"). value)*100);) it does not calculate correctly. As you can see, I don't know anything myself about this kinds of calculations :-S

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

You need to divide the new value (2019) by the old one (2018), then multiply by 100.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

I am probably missing something then. Because to me it looks like that is what I am doing: event.value = Math.round((this.getField("Omsetning 2019").value / this.getField("Omsetning 2018"). value)*100); 

 

As you see from my screenshots, if the value is the same it should be 0 % but with my formula it shows 100 %, and if the increase is for example 10, that should be 10 % increase in this example. What am I missing?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

OK, so it needs to be ("Omsetning 2019" - "Omsetning 2018")/"Omsetning 2018"

 

Edit: Sorry, the denominator needs to be "Omsetning 2018"...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

I am really sorry, I am trying to figure it out, but I don't understand how to put that in the total format. I just get an error: "SyntaxError: missing ) after argument list 1: på linje2" I am trying to correct the error, but I just don't get it. Can you write out the formula for me? Please 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines