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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

I want to do a calculation on my form that will sum fields only if the corresponding check boxes are select? Below is what I have tried but keep getting "Custom Expression Invalid". Is it possible. I can sum the three fields without the If statement.

Avatar

Level 3

=SUM((IF({Customize Total}=”True”, {Customize Total Amt},”0”)),(IF({Amendment}=”True”, {Amendment Amt},”0”)),(IF({New Volume Submitter}=”True”, {New VS Amt},”0”)))

3 Replies

Avatar

Community Advisor

I think your logic is sound but perhaps your syntax is off. So my two tips below:

1) Try to start simpler before adding more punctuation?

2) Also, sometimes I like to take my calculation out completely, save the blank field, and add the calculation back in. 🙂

Ideal calcs of this nature would start off like this:

SUM(IF(Field1=True,FieldAmt1,0),IF(Field2=True,FieldAmt2,0),IF(Field3=True,FieldAmt3,0))

i.e. in the simplest case where field names are one-word (super short and simple), you wouldn't have needed any additional fluff.

Even in this particular case, I haven't found that there's a problem between doing the above calc, and doing the same calc as a multi-word fieldname. But if I did have a problem, I would have definitely tackled it the way you did (curly brackets). However, I don't see a need for the additional parens at all--so those and the equals sign at the beginning might be messing you up. Your end result would look like this:

SUM(IF(Field 1=True,Field Amt1,0),IF(Field 2=True,Field Amt2,0),IF(Field 3=True,Field Amt3,0))

PS: usually I save the curly brackets for if I have punctuation inside my fieldname.

Avatar

Level 10

Hi Kendra, contact me for a WFPro crash course on custom form calculations and we'll fire up a GoToMeeting session. https://wf-pro.com/contact --Narayan

Avatar

Community Advisor

Kenda, if you're creating your calculation in another program, such as Word and copying it into the calculated field, make sure all your quote marks are straight quotes - they look like curly quotes in your note here and the calculated field won't read curly quotes.

I've started using NotePad if I'm creating my calculation elsewhere and copying it over, just for this reason.