Hopefully I have posted this in the appropriate forum (this could probably go into the JS forum as well and if so, my apologies.)
I have a monthly mileage log that has a field where the user will enter the the beginning vehicle odometer reading (this is a MANDATORY FIELD) at the beginning of the month OR when the vehicle is first used.
I then have 31 fields underneath corresponding to the days in a month with each field containing the ENDING odometer reading for that day. If the vehicle wasn't used on a particular day, that day's field would be blank. At the very bottom would be a "total miles" field. As a example, the data would be like this:
Beginning Mileage: 111,111
TOTAL MILEAGE 2,989
"Total mileage" = "Beginning Mileage" MINUS "the odometer reading of the 31st day AKA the LAST ENTRY FOR THAT MONTH"
Therein lies my issue. How can I make the "total mileage" field be dynamic? Let's say the vehicle was only used from the 5th through the 10th, how can I have the "total mileage" field display the correct odometer reading?
Hopefully, I explained this well enough for someone to help me and all help will be greatly appreciated.
In the total mileage, you could set up two variables, one for Max and one for Min and then subtract them.
var maxMiles = Max(mileage[*])
var minMiles = Min(mileage[*])
$ = maxMiles - minMiles
This is based on the script being in the calculate event of the total field. Also it depends on how you have set up the table. If the rows have the same name: eg Row1, Row1, Row1,... Row1 and the mileage field is named the same in each row, then the script may look like: