How to sum up values for all details records?

I am using a dynamic table that gets splitted over serveral pages. There is a transportline on each page as well as a subtotal field. How do I sum up the complete total value to be placed beneath the table?

Hello Thomas,

By default, when you use the Dynamic Table wizard and choose to add the subtotal and transport lines, it becomes a running total, not a subtotal for the current page. What I mean by this is that the page 1 subtotal is for all the items on page 1 which is then copied over to the transport line on page 2. The page 2 subtotal is the transport line + items on page 2 (so, page 1 + page 2). The last page is the full subtotal of all items in the table wizard.

You can study how this is done (and modify it to your needs) by taking a look at the different scripts created by the Dynamic Table wizard in the Scripts pane.

Hi Evie,

wow - fast answer! :slight_smile:

Ok, what I want to achieve is a “SUBTOTAL” - caption with the SUBTOTAL-value on every “middle” page and a “TOTAL”-caption with the TOTAL-value below the last line of the table; now I always get the “SUBTOTAL” - caption as the last line of the table.

I just came back from a 1-week vacation so I’m fast on the dial :stuck_out_tongue:

If all you’d like ot change is the actual caption, then there’s an easy way. While in Design mode, click on the table row where the SUBTOTAL caption appears, then use the “Select Row” option either in the toolbar or the contextual menu. Select “Insert row below”. Add the “TOTAL” caption in this new row, and duplicate the @subtotal@ placeholder.

Now, with either row selected you’ll see in the Attributes pane on the right that you have options “Show Row” that determines when, in a multipage dynamic table, a row appears (the whole row, not a single cell, needs to be selected). You’ll need to do 2 things. First, the new “Total” row you just added should have the “Subtotal Line” checked. Second, you need to change the “Subtotal” row’s “Show Row” to “Before Page Break” and the “Total” row to “At end of table”.

I believe you also will have to make sure the cell where the @subtotal@ attribute appears in your Totals line has the same “Class” attribute.

Or, by the way, if you’re comfortable with HTML, you can just duplicate the whole of the subtotal line to ensure all the code remains the same, adjust the caption for Total and then change only the “Show Row” attribute for that one.

I think I’ll add this to my list of short feature-based animations that we’ll be starting to produce soon. Good material :slight_smile:

Hi,

If I have created a script that builds a detail table row by row using HTML or a snippet, and my end user decides they want to now add totals to it after its been coded, can you show an example of how to sum up values from the code please?

thanks!

Hi Lou,

Beyond the scripts that are already present when creating a dynamic table, I don’t have any further examples. It’s basically looping through the rows and adding the total itself, as far as I understand it.

Please, in the future, open a new topic instead of commenting on an earlier one - it makes it much easier to discuss more without triggering notifications for other clients… You can refer to another topic easily.

Hi Evie,

I tried your suggestion, but somehow I didn’t manage it to work. I will try again.

ON the other hand, I remembered to practice the golden rule in printing: never calculate the TOTAL in your printing job; only calculate SUBTOTALS. The TOTAL must(!) be taken from the original data file. Otherwise you may end up in trouble - due to rounding differences…

Horrido,

Thomas