# Discussion

### I'm looking for a javascript to do a calculation.

posted on June 6

I'm thinking a javascript but don't know have to do this. I was wondering if anybody has a script that will produce this or guide me in the right direction.

User selects field "RU", User inputs a mileage number in field "Total Mileage"

Laserfiche does it calculation for field "Total All Trips" , field "tmr110" and field "tmr210"

And for the "tmr110" and "tmr210" I can get the running total for each unit separately like in the pic.

On my second picture when I select a unit 110 I would to get a calculation result from "tmr110" of the above picture and the same for "tmr210". Then when the user selects on of the fields below, I would like for the percentage field to do this calculation and display it in the percentage field.

percent110 = tmr110/TotalAllTrips

percent210 = tmr210/TotalAllTrips

0 0
replied on June 7

Nice it works great. Now, how do you round it off to a whole number?

0 0
replied on June 7

By either using ROUND formula(see https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Default.htm#../Subsystems/Forms/Content/FieldCalculations.htm ), or using a number field with 0 decimal place instead.

1 0
replied on June 8

Got it!!!! Thank you soooo much for ALL your help. Task completed!!!!

0 0
replied on June 7

I tried it with no luck. Here is my code with pictures.

=IF(INDEX(Funding_Stream. TMR_ReportingUnitDrop,ROW())=110, DIV(tmr110, TMR_GrandTotalMileage)*100, IF(INDEX(Funding_Stream. TMR_ReportingUnitDrop,ROW())=210, DIV(tmr210, TMR_GrandTotalMileage)*100, ""))

Below is the percent field I placed the fx

replied on June 6

Hi Carlos,

Field calculation should still be able to work in second picture. You can try

`=IF(INDEX(Table_1.Column_1,ROW())=110, DIV(tmr110, Total_All_Trips)*100, IF(INDEX(Table_1.Column_1,ROW())=210, DIV(tmr210, Total_All_Trips)*100, ""))`

where Table_1 is the second table and Column_1 is the unit drop-down.

1 0
You are not allowed to follow up in this post.