Skip to main content
Known Participant
April 12, 2016
Answered

Is it possible to convert excel function if(and to a custom calculation script

  • April 12, 2016
  • 1 reply
  • 1139 views

Our field staff use a lot of Excel files for project documentation.  Our organization is moving to iPads instead of laptops and we have found that fillable PDFs are a great resource for our staff.  I have created many of these forms which contain multiple rows and I'm just beginning to learn how to write custom calculation scripts.  I have a calculation that is more complex than most and I'm not sure if this can be written in script.

=IF(I6<0.7,G6*0.8,IF(AND(I6>=0.7,I6<0.8),G6*0.85,IF(AND(I6>=0.8,I6<0.9),G6*0.9,IF(AND(I6>=0.9,I6<=1.1),G6*1,IF(AND(I6>1.1,I6<=1.2),G6*1.1,IF(AND(I6>1.2,I6<=1.3),G6*1.15,"extra work"))))))

I6 is OverdepthRow1

G6 is WithDowelsRow1

I think I understand how to begin

var v1 = get.thisField("OverdepthRow1").value;

var v2 = get.thisField("WithDowelsRow1").value;

if(v1<0.7){

var result = v2 * 0.8

event.value = result}

else if(v1>=0.7 ----------------Now I don't know what to do!!!

Hopefully I've used the correct parenthesis and curly brackets in the right places.

I appreciate your help and guidance.

Thanks

Rhonda

This topic has been closed for replies.
Correct answer George_Johnson

I'm sorry, I made a mistake with those first two lines. I corrected one problem but introduced another. They should be:

var v1 = +getField("OverdepthRow1").value;

var v2 = +getField("WithDowelsRow1").value;

1 reply

Inspiring
April 12, 2016

The first two lines should be:

var v1 = +getField("OverdepthRow1");

var v2 = +getField("WithDowelsRow1");

Your next 3 lines are correct and the code should continue on like:

else if (v1 >= 0.7 && v1 < 0.8) {

    event.value = v2 * 0.85;

} else if (v1 >= 0.8 && v1 < 0.9) {

    event.value = v2 * 0.9;

}  else if...

// and so on until...

} else {

    event.value = "extra work";

}

Known Participant
April 12, 2016

Thank you so much, I will get right to work on this!

Rhonda