Expand my Community achievements bar.

FormCalc Multiply Table Cell by "x" and then Add to Other Cells

Avatar

Former Community Member

Hello,

I am trying to add a column of table cells together, which I know how to do, but for two of them, I need to multiply them by a value first, and then add all the cells in the column together. I can't seem to get the syntax right. Here is what I have:

sum(Cell2a*0.51) + (Cell3a*0.555) + (Cell4a + Cell5a + Cell6a + Cell7a + Cell8a)

Can anyone help me get this straight, so there are no more errors?

Regards,

ZeroZone

7 Replies

Avatar

Level 10

Hi,

The FormCalc sum function is comma separated:

sum((Cell2a*0.51), (Cell3a*0.555), Cell4a, Cell5a, Cell6a, Cell7a, Cell8a)

Hope that helps,

Niall

Avatar

Former Community Member

Unfortunately I might have something else wrong. I now have this error:

Capture.PNG

Regards,

ZeroZone

Avatar

Level 10

Hi,

It appears that while the object with the script can see most of the cells, it either:

  • can't see Cell8a; OR
  • Cell8a is called something else.

Check the reference to Cel8a. It may be in a different row or subform. Have a look here for a disucssion on object references: http://assure.ly/kUP02y.

Hope that helps,

Niall

Avatar

Former Community Member

oh no, I just realized I was trying to go the wrong way in the table. I need to do this by column, not row, so this is what I have now (and it's still giving me an error).

sum(Table2.Row[*].Cell2[*]), (Cell2a*0.51), (Cell2b*0.555)

where I need Cell 2a to multiply by 0.51 and Cell 2b to multiply by 0.555 and then be added to the rest of the cells in that column (Column 2).

ZeroZone

Avatar

Level 10

Hi,

A couple of things:

  • You don't have a closing bracket on the sum function. Also if you have trouble with the script then click the Check Syntax button in the Script Editor.
  • Cell2 is nearly there (see below), but are Cell2a and Cell2b in a Row??? If so you would need to specify that Row.
  • Is the row named "Row" OR "Row1"???

sum(Table2.Row[*].Cell2), (Cell2a*0.51), (Cell2b*0.555))

Niall

Avatar

Former Community Member

Hi Niall,

I was still getting an error message, and then just decided to try and remove the closing bracket after Cell2 and it worked! Yay! Thank you!

Regards,

ZeroZone

Message was edited by: zerozone110

Avatar

Former Community Member

Correct Answer:

sum(Table2.Row[*].Cell2, (Row[1].Cell2a*0.51), (Row[2].Cell2b*0.555))