Expand my Community achievements bar.

SOLVED

How to add numeric fields together

Avatar

Level 2

I knew how to do this once, but have now forgotten.

 

I have a form where I need to sum the values from 7 fields into an 8th one.

I've tried using JavaScript and FormCalc and tried all sorts of scripting examples but I can't make it work.

Perhaps I have the fields buried too deep inside sub sub forms?

I know it should be a basic thing to do, but my brain is just not working right now.

I'd appreciate any help.

Screenshot 2021-09-09 150311.jpg

 

1 Accepted Solution

Avatar

Correct answer by
Employee

Can you try changing it to "antiracism" or "anti_racism" under the subform "grandchallengesyessf"

Sum(antiracism, quantumscience, climateresilence, scienceliteracy, earlychildhood, sustainablefood, healthequity)

 

from 

 

Sum(anti-racism, quantumscience, climateresilence, scienceliteracy, earlychildhood, sustainablefood, healthequity)

 

I hope this will help.

View solution in original post

6 Replies

Avatar

Level 10

In FormCalc you can use the Sum() method i the calculate event of the total field. Just add the names of the fields to be summarised.

 

Sum(anti-racism, quantumscience).

Avatar

Level 2

I'm doing something wrong, since I'm getting an error message.

With FormCalc, run at Client...

 

form1.titlesponsorsf.titlesponsordatasf.grandchallengessf.grandchallengesyessf.totalpercentages::calculate - (FormCalc, client)

 

Sum(anti-racism, quantumscience, climateresilence, scienceliteracy, earlychildhood, sustainablefood, healthequity)

 

error message.jpg

Avatar

Correct answer by
Employee

Can you try changing it to "antiracism" or "anti_racism" under the subform "grandchallengesyessf"

Sum(antiracism, quantumscience, climateresilence, scienceliteracy, earlychildhood, sustainablefood, healthequity)

 

from 

 

Sum(anti-racism, quantumscience, climateresilence, scienceliteracy, earlychildhood, sustainablefood, healthequity)

 

I hope this will help.

Avatar

Employee

the others have spotted the issue with the field name. 

Generally: Never use operators such as "-" or "+" in a field name even if Designer does not prevent you from doing so. Latest in scripting will this fall on your toes. If you want to structure your field names use "_" or camel case like quantumScience ...

Avatar

Level 2

Thank you all for your help.

It is greatly appreciated!