Skip to main content
edited body
Source Link
Brian Fitzpatrick
  • 2.4k
  • 1
  • 21
  • 44
Totals = w*(sum of cols marked "P")+x*(sum of cols marked "Q")
         +y*(sum of cols marked "E")+z*(sum of cols marked "E""F")
Totals = w*(sum of cols marked "P")+x*(sum of cols marked "Q")
         +y*(sum of cols marked "E")+z*(sum of cols marked "E")
Totals = w*(sum of cols marked "P")+x*(sum of cols marked "Q")
         +y*(sum of cols marked "E")+z*(sum of cols marked "F")
Source Link
Brian Fitzpatrick
  • 2.4k
  • 1
  • 21
  • 44

Can columns of an org table be grouped to conveniently work with data?

I have an org table

|        |        | P1 | P2 | P3 | P4 | Q1 | Q2 |  E1 |  E2 |   F |
|--------+--------+----+----+----+----+----+----+-----+-----+-----|
|        | Totals | 20 | 40 | 35 | 20 | 50 | 45 | 100 | 100 | 200 |
|--------+--------+----+----+----+----+----+----+-----+-----+-----|
| John   |        | 18 | 18 | 15 |  0 | 45 | 22 |  45 |  97 | 112 |
| Paul   |        |  4 | 12 |  4 |  8 | 10 | 14 |  31 |  58 | 158 |
| George |        | 15 | 34 | 32 | 16 | 46 | 12 |  94 |  46 | 141 |
| Ringo  |        | 20 | 17 | 25 |  1 | 49 | 16 |  61 |  52 | 129 |

I would like to fill in the column Totals with a weighted sum of the other columns. The weighted sum should have a formula

Totals = w*(P1+P2+P3+P4)+x*(Q1+Q2)+y*(E1+E2)+z*(F)

Where w, x, y, and z are defined constants.

This specific formula is easy to write down. My problem is that I'd like the formula to respond when I add columns to the table. So my formula should really be something like

Totals = w*(sum of cols marked "P")+x*(sum of cols marked "Q")
         +y*(sum of cols marked "E")+z*(sum of cols marked "E")

Thus when my table is changed to

|        |        | P1 | P2 | P3 | P4 | P5 | Q1 | Q2 |  E1 |  E2 |  E3 |   F |
|--------+--------+----+----+----+----+----+----+----+-----+-----+-----+-----|
|        | Totals | 20 | 40 | 35 | 20 | 40 | 50 | 45 | 100 | 100 | 100 | 200 |
|--------+--------+----+----+----+----+----+----+----+-----+-----+-----+-----|
| John   |        | 18 | 18 | 15 |  0 | 40 | 45 | 22 |  45 |  97 |  65 | 112 |
| Paul   |        |  4 | 12 |  4 |  8 | 33 | 10 | 14 |  31 |  58 |  45 | 158 |
| George |        | 15 | 34 | 32 | 16 | 24 | 46 | 12 |  94 |  46 |  78 | 141 |
| Ringo  |        | 20 | 17 | 25 |  1 | 38 | 49 | 16 |  61 |  52 |  65 | 129 |

My formula should become

Totals = w*(P1+P2+P3+P4+P5)+x*(Q1+Q2)+y*(E1+E2+E3)+z*(F)

Is there a way to do this?