You are viewing limited content. For full access, please sign in.

Question

Question

Totals in Table

asked on June 12, 2019

I am trying to do a total in a table for total for Day and Total for Week. 

I cant figure out the calculation correctly. 

Like this. I'll need both calculations. 

0 0

Replies

replied on June 12, 2019

That usually happens when you have certain functions and empty fields. Off the top of my head, I can't remember which one, but either MULT or PRODUCT will fail if one of the fields is empty.

If you post your formula, it would help narrow things down.

Since you have a fixed number of rows, it is not impossible to have the totals in the same table, however, it is definitely going to make everything a lot more complicated.

0 0
replied on June 12, 2019

I used sum.  

0 0
replied on June 12, 2019 Show version history

It will require significantly more to work in a table.

SUM will automatically sum all rows in a column, so you need to wrap each variable in an INDEX function so it only adds for the current row.

For example,

=SUM(INDEX(Table.Column1,ROW()),INDEX(Table.Column1,ROW()))

The problem you're going to have is that you can't put a calculation in just your "Total For Day" row without affecting the Breakfast, Lunch, and Dinner rows.

0 0
replied on June 13, 2019

Do you have any other suggestions to get what i need? 

0 0
replied on June 13, 2019

This is what I do in these situations:

  1. Create a separate table with 1 fixed row for your totals
  2. Use a function in each column of the "totals" table to calculate the sum of the corresponding column of the main table
    • i.e., SUM(Table1.Column1)| SUM(Table1.Column2), etc. replacing those with your variables of course
  3. In your main table only put a function in the last column
    • SUM(INDEX(Table1.Column1,ROW()),INDEX(Table1.Column2,ROW()),......) and so on
    • INDEX({variable},ROW()) is what tells the formula to pull the column variable for the "current" row with an automatic index

Now you will have row sums in your main table and column sums in the totals table.

To make it look nice, add a "totalsTable" class to the "totals" table, and use something like this in the CSS

.totalsTable .cf-section-header,
.totalsTable th label {
  display: none !important;
}

.totalsTable {
  padding-top: 0px !important;
}

That will hide the title and heading for the totals table to make it more like it is just part of the main table (if you want that)

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.