0

In my org table I use the next formula to sum rows 1,5,7 of column 6.

|   | Start date       | End date         | Task     | State     | Duration (hours) |
|---+------------------+------------------+----------+-----------+------------------|
| # | 15.08.2019 10:30 | 15.08.2019 12:00 | T-320    | Taken     |             1.50 |
| # | 15.08.2019 13:00 | 15.08.2019 14:00 | T-320    | Taken     |             1.00 |
| # | 15.08.2019 14:30 | 15.08.2019 18:00 | T-321    | Taken     |             3.50 |
| # | 16.08.2019 10:30 | 16.08.2019 12:00 | T-321    | Taken     |             1.50 |
| # | 16.08.2019 13:30 | 16.08.2019 15:30 | T-321    | Taken     |             2.00 |
| # | 16.08.2019 15:30 | 16.08.2019 18:00 | T-322    | Taken     |             2.50 |
| # | 28.08.2019 14:00 | 28.08.2019 17:00 | T-330    | Taken     |             3.00 |
| # | 28.08.2019 17:00 | 28.08.2019 18:00 | T-331    | Taken     |             1.00 |
| # | 29.08.2019 10:30 | 29.08.2019 15:00 | INIT-117 | Done      |             4.50 |
| # | 29.08.2019 15:30 | 29.08.2019 16:00 | FM-222   | Done      |             0.50 |
| # | 29.08.2019 16:00 | 29.08.2019 18:00 | T-331    | Postponed |             2.00 |
| # | 30.08.2019 10:30 | 30.08.2019 12:00 | INIT-121 | Taken     |             1.50 |
| # | 30.08.2019 13:30 | 30.08.2019 21:00 | INIT-121 | Taken     |             7.50 |
|---+------------------+------------------+----------+-----------+------------------|
|   |                  |                  |          |           |              6.5 |

#+TBLFM: $6=$3-$2;t::@>$6=vsum(subscr(@I$6..@II$6,{1,5,7}));%.2f

Nice. It's work fine.

But I have a question: What is the return value of subscr?

  • 1
    I can't get your formula to work on a simple table, can you provide a working example? subscr here refers to subscripts. – Tyler Sep 5 at 21:56
  • @Tyler I update my post – a_subscriber Sep 6 at 6:56
2

I've given you a link to the calc manual in my other answer.

The manual describes that subscr is a synonym of mrow and the extension to vectors of indexes is described in the paragraph on mrow:

If the index is itself a vector of integers, the result is a vector of the corresponding elements of the input vector, or a matrix of the corresponding rows of the input matrix. This command can be used to obtain any permutation of a vector.

Furthermore, the org-manual says that with org tables you have all the power of calc at your fingertips.

Note further that @I$6..@II$6 in the org table formula expands to the calc vector [1.50,1.00,3.50,1.50,2.00,2.50,3.00,1.00,4.50,0.50,2.00,1.50,7.50] and that your expanded formula looks like:

vsum(subscr([1.50,1.00,3.50,1.50,2.00,2.50,3.00,1.00,4.50,0.50,2.00,1.50,7.50],{1,5,7}))

You can discover that for yourself by debugging your org table formula. Switch on Tbl -> Debug Formulas before evaluating the formula.

  • what "other answer" are you referring to? – NickD Sep 6 at 12:24
  • @NickD Thanks for the notice. I just forgot to add the link. – Tobias Sep 6 at 14:02

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.