Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

help please javascript - sumif (X:Y,>"0")*1000000 equivalent

Community Beginner ,
Aug 16, 2016 Aug 16, 2016

Hello everyone,

I am hoping you can help me solve a problem.

I am new to pdf forms and javascript.

I have set up a basic form that functions as a calculator.

The form was originally in excel and I was able to use the formula SUMIF(X:Y,>"0")*1000000

All the formula does is checks for positive values in a range and then sums only the positive values eventually multiplying them by $1 000,000.

I am trying to have the result display in a form text box (light blue box with the $2,119,244,485.00 number)

TOPICS
Acrobat SDK and JavaScript , Windows
604
Translate
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 Expert ,
Aug 16, 2016 Aug 16, 2016

What are the names of the fields you want to use for this calculation?

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

Hi there thank you for your reply,

the field names are;

The field where I want the output is named "Estimated Funding Requirement Over and Above" that's the light blue cell in the form 5th one in the first area.

in the formula SUMIF(X:Y>"0")*1000000

X:Y range is named: A39, B39, C39, D39, E39, F39, G39, H39, I39, J39, K39, L39, M39, N39, O39

0 is named: Zero

1000000 is named: One Million

thank you

Translate
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 Expert ,
Aug 16, 2016 Aug 16, 2016

Let's say they are called "Field1" and "Field2". You can use this code as the custom calculation script of the total field:

var fields = ["Field1", "Field2"];

var total = 0;

for (var i in fields) {

    var f = this.getField(fields);

    var v = Number(f.valueAsString);

    if (v>0) total+=v;

}

event.value = total * 1000000;

Translate
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 ,
Aug 16, 2016 Aug 16, 2016
LATEST

thank you very much ill try as soon as I get home!

Translate
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