You are viewing limited content. For full access, please sign in.

Question

Question

Calculating Forms Field based on Checkbox

asked on February 14, 2018 Show version history

Hello,

 

I am currently working on a forms calculation and can't seem to get it right.

 

What I am trying to do logically seems simple.

 

I have field called Mileage that gets filled in with the miles it takes to get from one location to another.

What I have added is a checkbox field labeled Round Trip with a box for Yes and No.

 

When the submitted selects the "Yes" checkbox, I need the Mileage field to multiply by 2.

 

As of right now, my calculation is set to:

 

=IF(Inner_District_Amounts.Round_Trip.Yes)MULT(2)

 

I tested and this does not work. I have tried a few other things as well with no luck.

 

This may be simple but I could use some assistance.

 

I have also attached a screen shot to show what the fields look like filled out.

 

Thanks!

 

 

 

 

2018-02-14 12_15_04-Layout _ Laserfiche Forms.jpg
Lookup Rule.jpg
Lookup Rule.jpg (47.35 KB)
0 0

Replies

replied on February 14, 2018 Show version history

As I understand, the MULT function will only multiply whatever is explicit in the parentheses, so you would need to state the variable that you are multiplying by 2 in it.  For example:

 

=IF(Inner_District_Amounts.Round_Trip.Yes)MULT(2,SUB(Inner_District_Amounts.To,Inner_District_Amounts.From)), which would calculate the difference between To and From, then multiply that difference by 2.

0 0
replied on February 14, 2018

If statement syntax is IF(Condition,True,False) so you'd want something like 

IF(Inner_District_Amounts.Round_Trip.Yes,    #if round trip is checked

Multiply((To - From) x 2),                                     #take the To minus From and times by 2

To - From )                                                            #Otherwise just do To minus From

 

0 0
replied on February 14, 2018

Jared,

My apologies as I labeled my screen shot wrong. I have updated the screen shots to better help explain.

 

What is happening is that there is a look up rule that fills in the Mileage field when the To and From fields match a value in the database table being utilized.

So in reality, It would more like, whatever the value of the Mileage field is times 2.

 

Thanks!

0 0
replied on February 14, 2018

Oh, then I might use a hidden field. You have your To and From fields, do the lookup and store that in a hidden field called Initial Mileage or something. Then the calculation for your showing Mileage field would be

IF(Inner_District_Amounts.Round_Trip.Yes,

Initial_Mileage * 2, 

Initial_Mileage)

The hidden field will store the lookup value, then the showing field would either show the hidden lookup value times 2, or just show that value as is. 

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

Sign in to reply to this post.