Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Trying to calculate sum of column values in an add/delete a row table

Avatar

Level 1

I am very new to live cycle and am learning as I go, basically web searching for help and trial and error (lots!).  I am trying to figure out what code to use in each of the 8 columns of a table I have in order to sum each columns' user entered value.  The table has a header row, and then row 1 has subform with a "+" and a "-" button to add and remove the row.  The tabel functions for adding a row and removing a row (even a specific row) are working fine.   I do not need to sum each row.  I need to calculate a sum at the bottom of 8 of the columns, and they are all numeric field objects.  From what I can find, I need to add a Row2 to the table that will be my totals row, but I don't know what to do with each cell for that row for the 8 columns I need to individually calculate the totals for.

Any help is greatly appreciated!

6 Replies

Avatar

Level 10

You can use the asterisk accessor to address multiple instances of a repeatable object, such as a table row.

 

Given your row contains a field named "total", you can add a footer row with a calculation script to summarize the values the "total" field in all instances of the row. 

 

$ = Sum(row[*].total)

 

 

Avatar

Level 1
I must not be doing something right because I keep getting an error.

Avatar

Level 10

Make sure you've selected FormCalc not JavaScript as scripting language.

 

radzmar_0-1584694087988.png

 

Avatar

Level 1

I did that, but I still have something wrong. This is the error I get:

ktnewk02_0-1584748224258.png

This is my hierarchy:

 

ktnewk02_4-1584749625692.png

 

Then I thought maybe you meant to I need to use the cell name that I am trying to total the values of in place of the word "total" in your script.  So I tried using the name of the column cell I am trying to total the values for which for the first column is 'BottlesOutU'.  This is what I tried:   $=Sum(row[*].BottlesOutU)   and this, $=Sum(BottlesOutU[*].total)       I still get an error saying the accessor is unknown:

ktnewk02_3-1584749104975.png

 

I added a row (named SampleTotals) after Row1 and any added row the end user makes.  I need that row to show the calculated total value for each of the columns that have a numeric field.  I am very new to LC and am really learning as I go- it is probably something easy I am missing.  This is my table:

ktnewk02_2-1584748556213.png

Thanks for any insight you can provide!

 

Avatar

Level 10

Ok, your repatable row is named "Row1". To calculate the summary of all instances of the field "BottlesOutU" the FormCalc script is as follows.

 

$ = Sum(Row1[*].BottlesOutU)