# Should be a simple equation but [RESOLVED]

Hi, I’m trying to add all of the values together, as a total, from a multi-select field.

If choice 1 has a value of 10, and choice 2 has a value of 5… If they’re both selected, I’d like to populate the ‘total field’ with the sum of those selections (in this case it’d be 15 obvs).

My formula knowledge isn’t very good…

Hi Mark. The multi-select field is not supported in calculations. Can you use a checkbox field instead? If so, you can use that in a calculation.

Hey Chris, thanks for your reply… Checkboxes, would work equally well, and in fact, I’m working on that as an alternative, but I’ve got a similar problem… I can’t seem to add up the values… If choice 1’s Value is ‘10’ and choice 2’s Value is ‘5’. I try to perform a sum, but my returned total is 105 (just the values in sequence, as a number)… It’s kinda perplexing, I thought totalling up checkbox values would be a piece of cake, I must be missing something stupid

Hi Mark. First, try the `:value` modifier on the merge tag:

If that does not work, please export your form and share it with a file-sharing service, then post the link here so we can look at the form. Thank you.

OK, so for anyone looking to add up the values of checkboxes (either dynamically populated or not), here’s the solution. First thing’s first you’ll need Gravity Wiz ‘Populate Anything’… Then, point your ‘total’ field to the checkbox field by @ing it from the ‘default value’ socket, ie @{:10}

``````add_filter( 'gppa_live_merge_tag_value_123_10', function( \$merge_tag_match_value ) {
\$values = explode( ',', \$merge_tag_match_value );
\$sum = 0;
if ( is_array( \$values ) ){
foreach (\$values as \$value){
\$sum+= (int)\$value;
}
\$merge_tag_match_value = \$sum;
}
return \$merge_tag_match_value;
} );
``````

…Where ‘123’ is your form ID and ‘10’ is your checkbox field ID.

Works like a charm. You can close this now and mark as resolved. Thanks for your help

1 Like