Skip to main content
carolpaspasia
New Participant
June 26, 2023
Question

Rounding Calculations Don't Work

  • June 26, 2023
  • 2 replies
  • 862 views

Hello

I have an expense report that is driving me crazy.

Travel Expense Area specifically.

 

e.g.

 Step 1 - MilesRow 1 is number of miles manually entered'

Step 2-   MCost1 is the product of MilesRow1 x 0.655 (current rate)

I have twelve lines.

Step 3- MilesTOTALMILEAGE is sum of all MilesRow lines 1-12
Step 4- Mileage Cost Total is sum of all MCOST rows 1-12.  (This is the one not working)

The numbers add up across, but do not calculate properly in the final Mileage Cost Total

Attached is the form. As you can see. with the numbers I plugged in. It should be $24.25 not $24.24. This wreaks havoc wth accounting.  All are formatted to 2 decimals. All are calculated using simplified notations or Value is the sum of...

 

HELP!

 

 

 

This topic has been closed for replies.

2 replies

try67
Community Expert
June 27, 2023

You need to fix the fields calculation order. The totals should appear at the bottom of the list.

carolpaspasia
New Participant
June 27, 2023

Thanks but i did that and didnt change anything

 

 

try67
Community Expert
June 27, 2023

The issue with the rounding is that the numbers you're seeing are not the actual field values (because of the Format options you selected). If you click the Cost fields you'll see that they change from 0.65 to 0.655. The latter is the actual value. If you want to round them you need to use a script. So, for example, for the first field use this code:

 

event.value = (Number(this.getField("MilesRow1").valueAsString) * 0.655).toFixed(2);

 

Do that to all the fields and their display values will match their actual ones. You should also remove the Format setting, so the real value is no longer hidden.

carolpaspasia
New Participant
June 26, 2023

Correction I put in 1 mile in each area and it should add up to .665 x 3= 1.98 but it shows 1.97