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

Question

Question

Calculations

asked on February 27, 2017

I have created a dummy form to see if I could use the calculations feature. This is my first time using it. For some reason it won't add the single line fields together. 

0 0

Answer

SELECTED ANSWER
replied on February 27, 2017

I believe that these functions will work starting with Forms 10.2.  For a Sum function, your field type will have to be a Number and make sure that you form your calculation statement using the variable and not the field label.  Ex:  Sum(n1,n2)

1 0
replied on February 27, 2017

Okay figured this was a 10.2 update. I guess I just need to go ahead and get the ball rolling on that update.

0 0
replied on February 27, 2017 Show version history

Calculations were supported beginning with 10.0. The issue you are running into is that the fields you are summing are Single Line fields and not Number fields as Glenn distinguished. The reason 1 + 1 = 0 for you is because per the OpenFormula standard, Text values become 0 when cast as a Number type, e.g. for addition, and values from a Single Line field are treated as Text types. So what's happening in your calculation is you are performing "1" + "1" = 0 + 0 = 0. If you change the field type to Number, you should be able to get it to work without needing to update to 10.2 (which update would not address the root of the issue at hand).

Edit: Actually, if you have at least Forms 10.1, you can use the VALUE() function to attempt to get the numeric value of a string representation of a number. For example, =SUM(VALUE(Test1),VALUE(Test2))

I would actually recommend not using this and instead use Number types for operands which you know you'll have to sum, because then you get built-in validation that only numeric values will be entered; if you try to evaluate, say VALUE("Hello") and use that in a sum, you'll get a calculation error.

1 0
replied on February 28, 2017

Okay...I have changed all my single line fields to number fields. Everythings seems to be working now.

0 0
replied on February 28, 2017

@████████ when I add another row the calculation don't add correctly. Please see the below formula.

=SUM(PRODUCT(Leave_Requested.V___Full_Days,8), PRODUCT(Leave_Requested.V___Half_Days, 4))

0 0
replied on February 28, 2017

This is for a calculation in the same row in a table? In that case, you need at least Forms 10.1 and to use this calculation instead:

=SUM(PRODUCT(INDEX(Leave_Requested.V___Full_Days,ROW()),8), PRODUCT(INDEX(Leave_Requested.V___Half_Days,ROW()), 4))

In general, use INDEX(CollectionName.ItemName,ROW()) to reference an individual cell in the same row. The variable CollectionName.ItemName itself refers to the sequence of values in e.g. the table column. So I suspect what is happening in your formula at present is that the result you are getting is ((product of all values in V__Full_Days column) x 8) + ((product of all values in V__Half_Days column) x 4).

1 0
replied on February 28, 2017

Yes that is exactly what was happening. I have 10.1 and I plugged in the calculation. It works great.

1 0
replied on February 28, 2017

Great to hear it!

0 0

Replies

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

Sign in to reply to this post.