Skip to main content
cynbee3162
Participant
July 8, 2019
Answered

Formula help: adding up mileage fields then multiplying by .58 cent reimbursement rate.

  • July 8, 2019
  • 1 reply
  • 2792 views

It woked - then when I saved .pdf it was lost when I reopened it.  Then it would only work in some fields an not others.  Now it won't work at all.

// Get first field value, as a number

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

// Get second field value, as a number

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

// Get third field value, as a number

var v3 = +getField("MileagemilesRow3").value;

// Get fourth field value, as a number

var v4 = +getField("MileagemilesRow4").value;

// Get first field value, as a number

var v5 = +getField("MileagemilesRow5").value;

// Calculate and set this field's value to the result

event.value = .58 * (v1 + v5);

This topic has been closed for replies.
Correct answer cynbee3162

Where is your problem?

(0.0 + 0.0) * 0.58 is 0.0


Thank you for all your help.  There was a duplicate formula in another cell (which I had inadvertently copied) that was causing the problem.  But you had easier formulas to use.  Thank you, again!!!

1 reply

Bernd Alheit
Community Expert
Community Expert
July 9, 2019

You can use the simplified field notation:

(MileagemilesRow1 + MileagemilesRow5) * 0.58

October 31, 2019

I am having a similar issue, what am i doing wrong? with how I have it configured, it does not calculate the field AUTO: Mileage 1.0. I have 100 entered so it should calculate to $28 (100 miles x 0.28) but the value is $100.

 

*screenshot is attached, i cannot get it to upload

 
 
October 31, 2019

Sorry, I don't follow what you mean... Where did you place the code?


sorry i wasn't more clear. i put the code in both simplified field notation & custom calculation script. In simplified, i enter 100 & it calculates to $28 but the total (calculates the sum of all fields in this section) calculates $100 (it is calculating the value entered (100), not the value calculated ($28).

 

Thanks for jumping in & helping so quick. I spent hours online & watching videos trying to get it to work. You have been the most helpful!