Skip to main content
Participant
Dec 3, 2024 2:12 AM UTC
Answered

Validating calculation of total not individual components

Hello,

I'm creating a grant application form with the following items:

A = total cost of project

B = deduct total amount of funds already on hand

C = total grant amount being applied for

The calculation is A-B=C. 

 

The valadation is: $0=> C <= $100,000. 

 

If A = $150,000 and B = -$90,000, then C = $60,000.

Because the calculation is automatically updated as soon as A is entered (and B has not been entered), then  C = $150,000 which automatically triggers an error message.

 

What would be the script to allow A to be >= $100,000, but yet C still has to be <= $100,000 once A and B are entered.  I tried playing with an IF-THEN statement, but no luck.  I don't want users to enter B first as it seems counterintuituve to start with a negative number in this scenario.  Any suggestions?  Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Dec 4, 2024 5:35 AM UTC

Because the calculation is automatically updated as soon as A is entered
You can set in a script to calculate only when A and B fields are filled.

7 replies

try67
Community Expert
Community Expert
Dec 3, 2024 10:15 AM UTC

What should be the value of C if only A (or only B) are filled in, then?

Translate
murray01Author
Participant
Dec 3, 2024 3:44 PM UTC

The value of C is the total when A - B is calculated.  I don't want the value of C to be calculated and then validated until both A and B are entered.  At the validation, C must be <= $100,000.  The values of A and/or B could be "0".  

Example: A = $150,000 and B = -$90,000.

If you do the math on a piece of paper and as soon as you are finished writing $150,000, your brain doesn't trigger an error message because A is >=$100,000.  Rather, your brain waits for B to be written as -$90,000 before doing the calculation of $150,000-$90.000 and determing the result is $60,000 which is <=$100,000; thus, no error message gets triggered.

 

then C = $60,000.

Because the calculation is automatically updated as soon as A is entered (and B has not been entered), then  C = $150,000 which automatically triggers an error message.

Translate
try67
Community Expert
Community Expert
Dec 3, 2024 9:18 PM UTC

You can't validate a calculated field. Validation means checking the value and either accepting or rejecting it. This needs to be done in the fields that contain values the user enters, not ones with a calculated value.

You can replace the "bad" result with zero, or nothing, or "ERROR", but you can't reject it.

Translate
Bernd Alheit
Community Expert
Community Expert
Dec 3, 2024 4:50 AM UTC

What script do you use?

Translate
murray01Author
Participant
Dec 3, 2024 2:15 PM UTC

I don't have a script at the moment, so that is why I'm looking for a solution.  I'm very new to writing scripts.

Translate