Skip to main content
Inspiring
Aug 3, 2026 5:37 PM UTC
Answered

Can I calculate numbers in an InDesign table?

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

    jmlevy
    Community Expert
    jmlevyCommunity ExpertCorrect answer
    Community Expert
    Aug 4, 2026 2:21 PM UTC
    Dave Creamer of IDEAS
    Community Expert
    Community Expert
    Aug 3, 2026 7:42 PM UTC

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

    Translate
    David Creamer: Community Expert (ACI and ACE 1995-2023)
    PeterD-NJAuthor
    Inspiring
    Aug 3, 2026 6:57 PM UTC

    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.

    Translate
    rob day
    Community Expert
    Community Expert
    Aug 3, 2026 6:44 PM UTC

    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

     

     

    Translate
    Peter Kahrel
    Community Expert
    Community Expert
    Aug 4, 2026 9:31 AM UTC

    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.

    Translate
    PeterD-NJAuthor
    Inspiring
    Aug 4, 2026 1:53 PM UTC

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

    Translate
    rob day
    Community Expert
    Community Expert
    Aug 3, 2026 6:37 PM UTC

    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.

    Translate