Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Question regarding the SUM of numeric fields

Avatar

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
RoC1909
Level 1

30-11-2010

Hey all,

Hopefully I have posted this in the appropriate forum (this could probably go into the JS forum as well and if so, my apologies.)

My question:

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

1st                            111,200

2nd                           111,300

3rd                           

4th                            112,000

5th                            112,300

6th

7th                            113,000

...

...

...

31st                          114,100

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile
Niall_O_Donovan
Level 10

30-11-2010

Hi,

This is an example of where FormCalc has an advantage over JavaScript. There are built in functions in FormCalc for getting the maximum and minimum values.

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[0], Row1[1], Row1[2],... Row1[30] and the mileage field is named the same in each row, then the script may look like:

var maxMiles = Max(Row1[*].mileage[*])

Hope that helps,

Niall

Assure Dynamics

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile
Niall_O_Donovan
Level 10

30-11-2010

You're welcome Jon

Avatar

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
RoC1909
Level 1

30-11-2010

Upon re-reading what I said in my last post, I didn't mean it in a BAD way that your ideas made me "revamp" my form. On the contrary, I made my form much more efficient.

I also wanted to say that I really enjoyed your tips on creating dynamic tables that I found on your website.Very informative and very cool what a person can do with Acrobat.

Thanks again,

Jon

Avatar

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
RoC1909
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
RoC1909
Level 1

30-11-2010

Hi Niall,

Thanks for the help. It completely made me revamp my form.

Jon