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

SOLVED

FormCalc conditional sum problem

jparris67
Level 1
Level 1

I have a travel reimbursement form with numeric fields for all expenses and cash advances. I have two fields for totals: one for "Amount Due Traveler" and one for "Amount Due University." I need for the Total Expenses and Advances fields to be compared, and if Expenses are greater than Advances, the Amount Due Traveler should sum and leave the other field at $0. If the opposite is true, the Amount Due University should sum and leave the other field at $0.

 

I've tried different if then else statements and nothing seems to be working. I've done a lot of research and can't seem to find the answer.

 

What would be the proper way to write this in FormCalc?

FormCalc
1 Accepted Solution
Magus069
Correct answer by
Level 10
Level 10

Hi there,

 

I can't directly give you the solution at hand without the object references. Without the hierarchy, all I can give you is the syntax on how to make this work.

So technically, you need a calculate event for each fields which you need to input a calculated value or 0$, both will have the same syntax, but different outcome.

 

For the Amount Due Traveler it should look something like the following:

Amount Due Traveler :: calculate - FormCalc

if (Expenses gt Advances) then
	;Calculate Amount Due Traveler
else
	0
endif

 

and For the Amount Due University, it's simply the opposite

Amount Due University :: calculate - FormCalc

if (Expenses gt Advances) then
	0
else
	;Calculate Amount Due University
endif

 

You can always provide a screenshot with the hierarchy and the code you are testing if you need any more assistance.

 

You can always refer to the FormCalc User Reference for any question on how to use the language

I hope this will help.

 

View solution in original post

2 Replies
Magus069
Correct answer by
Level 10
Level 10

Hi there,

 

I can't directly give you the solution at hand without the object references. Without the hierarchy, all I can give you is the syntax on how to make this work.

So technically, you need a calculate event for each fields which you need to input a calculated value or 0$, both will have the same syntax, but different outcome.

 

For the Amount Due Traveler it should look something like the following:

Amount Due Traveler :: calculate - FormCalc

if (Expenses gt Advances) then
	;Calculate Amount Due Traveler
else
	0
endif

 

and For the Amount Due University, it's simply the opposite

Amount Due University :: calculate - FormCalc

if (Expenses gt Advances) then
	0
else
	;Calculate Amount Due University
endif

 

You can always provide a screenshot with the hierarchy and the code you are testing if you need any more assistance.

 

You can always refer to the FormCalc User Reference for any question on how to use the language

I hope this will help.

 

View solution in original post

jparris67
Level 1
Level 1

Oh my gosh, thank you! I'd tried everything, but making some adjustments, this is what worked:

 

Total due traveler:

if (TotalExpenses gt Advances) then
Sum(TotalExpenses-Advances)
else 0
endif

 

Total due university:

if (TotalExpenses lt Advances) then
Sum(Advances-TotalExpenses)
else 0
endif

 

Thanks again!