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
BedrockMission!

Learn more

View all

Sign in to view all badges

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

ktnewk02
Level 1
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!

column sum LiveCycle
6 Replies
radzmar
Level 10
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)

 

 

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

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

 

radzmar_0-1584694087988.png

 

ktnewk02
Level 1
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!

 

radzmar
Level 10
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)