Expand my Community achievements bar.

calculate column cells in tables

Avatar

Level 3

Good afternoon!  I'm trying to calculate a column of cells in a table.  Have viewed various templates which have tables to no avail and also searched and searched this and various other sites for solutions.  The answer seemed to be pretty clear, but didn't work for me.  Let me also say that the templates which come with Livecycle (purchase order and expense account) don't even look like tables in the hierarchy so I'm confused by that also . . .

In my table I'm only working with 2 cells while I figure this out.  I renamed the cells all same thing instead of name1, name2, etc.  My search for a solution seemed to indicate this when working with tables.  Unless I got that part wrong too.  Also, I notice that the formula used is something like: Sum(ExpenseAmount[*]) rather than the  sum (name [0], name [1]).  But, it doesn't work for me (these are examples, my cells are named something different).

Maybe I need to create some sections or subforms. . . . ? 

Thanks much for any help/guidance . . .

11 Replies

Avatar

Level 10

You are on the right track but you need to reference the table and row as well. You are correct in keeping the names the same as then the instance number in the square brackets lets you use wildcards in FormCalc for doing calculations.

So with your example you would want something like sum(Table1.Row1[*].name) this will go through the table and add the value of the "name" field for every row in the table.

Hope that helps!

Avatar

Level 3

Hey Jono,

It sort of helped - I can definitely get my brain around the associations.  I plugged in the formula and the names of my table/row/cell.  I must be getting close since I'm not getting an error message or warning message anymore, however it still doesn't calculate.

                  Table name = pg2table

            All rows named = row

Cells to calculate name = mhours

So I plugged in:  sum(pg2table.row[*].mhours) which didn't work.  I also did sum(pg2table.row[*].mhours[*]).  Which also didn't work.

My table has 2 or 3 body rows where all the cells are merged which sort of divide the body of the table.  I deleted these in case "jumping" cells which are not there was causing a problem, but that didn't help either.

The row that the formula cell is in, while actually in the middle of the table, is defined as a footer row - in case that makes any difference.  All the cells below the cell which calculates are named hours19, hours20, etc. so hopefully it's not gettin associations confused.  At any rate, no error messages .  .

Thanks very much for your help.  Let me know if you or others have any additional insights to add . . .

Avatar

Level 10

I'd double check that the script is set for FormCalc in the Script Editor and also that the script is on the Calculate event.

Other than that I'd have to see the form to figure out what's going on.

Avatar

Level 3

I can confirm Formcalc and Calculate event.

I can send it to you if you're not in the middle of a big project and have time/energy.  There is no strict deadline for the project that I'm working on so I've got time to continue searching.

Please advise.

Avatar

Level 10

I can take a look at it this weekend.

If you set up an account at acrobat.com you can upload the form there and then share it and post the link here.

Avatar

Level 3

Hey,

Very sorry so long in getting back - snow, sickness, and deadlines derailed me  . . .

The form is posted at:  https://acrobat.com/#d=OCBjzVmx43rP2MqTh1iuAw

My problem is getting the field "mhourstotal" to total.

No terrible hurry, any help is greatly appreciated!

MM

Avatar

Level 3

sorry, it's called Art Therapy Majors checklist - Test

Avatar

Level 10

Ah, looks like you just need to save the form as Dynamic - do a File > Save As > Adobe Dynamic XML Form.

Avatar

Level 3

That worked.  Geez, I'm a dummy!  I need to make a checklist when duplicating forms so I remember to do those small things

that I actually KNOW HOW to do.

Thanks so much for your help and patience!

Avatar

Level 10

That one catches everyone the first few times!

Though actually on thinking about it that code should work ok in a static

form too, so not sure what else is going on.

Avatar

Level 3

Well, it works now and it didn't before.  So, I'll just keep my fingers crossed and hope it stays that way

Thanks again~