0

I have this org-mode table:

| Category         | Category Budget | Needs Transfer |
|------------------+-----------------+----------------|
| Rent             |            3000 | t              |
| Internet         |             125 | t              |
| Food             |            1000 |                |
| Coffee           |             500 |                |
| Cellphone        |             120 | t              |
| Cigarettes       |             100 |                |
| Total            |            9945 |                |

I want the "Total" row, in the "Needs Transfer" column, to show the sum of all of the budgets that have "t" in their "Needs Transfer" column.

I already tried this solution to no avail:

@>$3 = '(apply '+ '(org-lookup-all "t" '(@2$3..@-1$3) '(@2$2..@-1$2) 'string=));E
2

You almost have it: you have quoted the org-lookup-call which prevents its evaluation; and you need to convert the strings in the second list to numbers in order to add them together. This works for me:

#+TBLFM: @>$3 = '(apply '+ (org-lookup-all "t" '(@2$3..@-1$3)  (mapcar #'string-to-number '(@2$2..@-1$2)) 'string=));E
| improve this answer | |
0

You may use the orgtbl-aggregate package available on http://melpa.org

Give a name to your table, for instance

#+name: mytable

Then create an aggregation block with C-c C-x i

#+BEGIN: aggregate :table "mytable" :cols "'Needs Transfer' vsum('Category Budget')"
| 'Needs Transfer' | vsum('Category Budget') |
|------------------+-------------------------|
| t                |                    3245 |
|                  |                   11545 |
#+END:

You get the sum for rows with t, and as a bonus the sum of rows without t.

| improve this answer | |

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.