1

I have a org table:

| a | b | c |
|---+---+---|
| 1 | 2 | i |
| 3 | 4 | j |
|---+---+---|
| 4 | 6 |   |

I want to multiply columns a and b and sum them up (except last row: 1*2+3*4) and put into the last cell:

| a | b | c |
|---+---+---|
| 1 | 2 | i |
| 3 | 4 | j |
|---+---+---|
| 4 | 6 | 14|

What is the formula to achieve this? I tried #+TBLFM: @>$>=sum($1 * $2) without luck.

My org version: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)

  • This is the scalar product of two vectors. Emacs calc (which is used by the table code in Org mode) can calculate the scalar product of two vectors using *, so the trick is to figure out how to specify the two vectors. @gigiair's answer shows you how to do that. – NickD Feb 22 at 16:14
4
 @4$3=(@2$1..@3$1)*(@2$2..@3$2)

or

 @>$>=(@<<$<..@>>$<)*(@<<$<<..@>>$<<)

or

 @>$>=(@I$1..@II$1)*(@I$2..@II$2)

using the horizontal lines to delimit instead of explicit row numbers.

The relevant section of the manual is dense but well-worth reading (and re-reading).

|improve this answer|||||
  • 1
    parentheses are not mandatory, but make the formula easyer to read. – gigiair Feb 22 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.