Skip to main content
Inspiring
August 3, 2026
Question

Can I calculate numbers in an InDesign table?

  • August 3, 2026
  • 8 replies
  • 71 views

I would like to be able to calculate row- and column totals automatically within InDesign if this is possible.

One one page of a large/complex document I have one table formatted exactly the way I want it to look, with numerical values that update regularly. There are column headers along the top, row headers on the left, column totals on the bottom, row totals on the right, and the grand totals in the bottom-right cell. All the cells inside the table contain only numbers or no data. The row totals on the right also require footnote references (*1, etc) that are detailed in text below the table.

For the last 25 years I’ve just been updating the numbers manually and using a calculator, but I have made mistakes on occasion. I’d rather not mess with Excel and importing/linking/etc; just a very simply way to add top-to bottom and left-to-right. Is it possible to do this? Please and thanks. Here is the table.
 

 

    8 replies

    Dave Creamer of IDEAS
    Community Expert
    Community Expert
    August 3, 2026

    DTPtools.com has a plugin to give Excel-like calculations. 

    David Creamer: Community Expert (ACI and ACE 1995-2023)
    PeterD-NJAuthor
    Inspiring
    August 3, 2026

    I update this table every few days—usually it’s just one number that changes two others, but still I’d like to automate this in the way Excel does it. I don’t know or understand programming or scripting, etc. I’m as far from being a “computer guy” as you can get. I just need a functional set of tools at my disposal.

    rob day
    Community Expert
    Community Expert
    August 3, 2026

    Here’s a crude example, which gets the sum of the row with a selection:

     

    var d = app.activeDocument
    var r = d.selection[0].parent.parentRow.cells
    var s = 0
    for (var i = 0; i < r.length; i++){
    s = s + Number(r[i].contents)
    };
    r[r.length-1].contents = s.toString()

     

    Before and after running the script

     

     

    Peter Kahrel
    Community Expert
    Community Expert
    August 4, 2026

    Remember that you needn’t cycle through the cells of a row: get the row’s content, which returns an array of strings:

    myTable.rows[1].contents;  // returns an array of strings

    That should process the table much quicker.

    PeterD-NJAuthor
    Inspiring
    August 4, 2026

    With respect, I have no idea what those words mean. What on Earth would I do with them?

    rob day
    Community Expert
    Community Expert
    August 3, 2026

    Hi ​@PeterD-NJ , It can be done via scripting. A more complex script could listen for a change to the cells’ contents and update the sum.