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

Question

Question

In version 10, how can you calculate a total based on 'values' assigned to checkboxes?

asked on November 30, 2015

I am excited about the new Excel style calculation feature in Forms version 10. I would like to use this to calculate the total based on certain checkboxes that are selected in a field. So for example, if I have four checkboxes in a field called Options, with visual values of A B C and D, and backend values of 10, 15, 23 and 45 assigned to each of them respectively, I'd like to know if

=Options 

will give me the total I need because Forms knows to add up the checkboxes that are checked, or if some other formatting is necessary?

0 0

Answer

APPROVED ANSWER
replied on November 30, 2015

Hi, I tried Michael's suggestion and made a checkbox with three fields (first;second;third) and then added a formula like this "=IF(Checkbox_1.first,10,0) + IF(Checkbox_1.second,20,0) + IF(Checkbox_1.third,30,0)" to the field I want the calculation to display. So when I clicked field 'first' and 'third' I got the value 40 to show.

2 0

Replies

replied on November 30, 2015

You can use the IF function in Forms' formula language to achieve the results you want. IF takes three arguments. The first argument must evaluate to a Boolean value, and if it's true, IF returns the second argument. If it's false, IF returns the third argument. So, pass the Boolean value that the checkbox returns as the first argument, 1 as the second, and 0 as the third argument, and multiply this by the base value.

2 0
replied on November 30, 2015

The new field calculations in Forms 10 currently looks at the checkbox variable you're using (individual variable per checkbox option) and returns a boolean value indicating if that option is checked or not. For your scenario, you'd still have to use JS like the suggestion mentioned here. This is something that's being looked into for a future release though.

0 0
replied on December 1, 2015

Great suggestions guys, thank you so much. Will be trying this and will report back.

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

Sign in to reply to this post.