Dynamic summing of all rows
-
Hello,
I am trying to do something rather simple but I cannot get it to work. I am trying to SUM all rows of a certain column representing the monetary value of items. Each row represents an item.
I’d like the total to be on the last row (like in Excel with a table). If the table size (number of rows) was “static” (not changing), that’d be very simple, but the table changes constantly (items are added or removed) so the number of rows will always change.
Therefore I cannot use something like
=Total Cost: {SUM(G2:G80)}USD
because the end row (G80) is “hardcoded” in the formula and when the table has 80+ rows, the SUM will be erroneous…I also cannot use
=Total Cost: {SUM(G2:G1000)}USD
The system returns “!ERROR! Cell G80 does not exist” because my table currently has only 79 rows… (it’s out of bound).Finally I tried to use a function inside of the SUM equation so it can start the SUM at G2 (the first data row after the header row) and end at NUM_ROWS-1 (which is the last data row before the footer row) but it returns all kind of errors…
How can this be achieved?
Second issue, I would like to display the number of rows on the page. Using a shortcode like
[table-info id=1 field=number_rows /]
returns “1”…. (By the way if the last ROW is used as footer, the above shortcode will return 0, not sure if this is a bug or not).
Thanks!
- The topic ‘Dynamic summing of all rows’ is closed to new replies.