7

I have the following org-mode table:

#+BEGIN: columnview :hlines 1 :id global
| /Project/      | Mon | Tue | Wed |  Thu | Fri |  Sat | Sun | /Total/ |
|----------------+-----+-----+-----+------+-----+------+-----+---------|
| AnotherProduct |     |     |     |      |     | 2.50 |     |         |
| Prototype      |     |     |     | 3.50 |     |      |     |         |
|----------------+-----+-----+-----+------+-----+------+-----+---------|
| /Daily/        |     |     |     |      |     |      |     |         |
#+TBLFM: @I$9..@II$9=vsum($2..$8);%.2f;::@II$2..@III$9='(format "%3.2f" (apply '+ '(@I..@II)));N;

and I get the error can't assign to hline relative reference when I run M-x org-table-recalculate. I looked over the org-mode references documentation and the gmane.org forums, but I did not find any reasons as to why the hline relative references could not be assigned.

This issue is related to the timesheet package on MELPA. I have filed an issue here: https://github.com/tmarble/timesheet.el/issues/3 but hopefully I have found the underlying problem, and hopefully it is reasonably fixable.

Here is some relevant info:

  • Org-mode version 8.3.1 (8.3.1-87-g4ef2c0-elpa @ /home/luke/.emacs.d/elpa/org-20150824/)

  • emacs-version: 24.5.1

  • ArchLinux OS: Linux 4.1.6-1-ARCH #1 SMP PREEMPT Mon Aug 17 08:52:28 CEST 2015 x86_64 GNU/Linux

7
  • Consider asking the Org-mode maintainer for a better error msg, if you think a user is unlikely to understand the msg.
    – Drew
    Aug 31, 2015 at 0:02
  • @Drew Do you have any suggestions about how I can ask the Org-mode maintainer? Is there an email or separate forum that I should use? I think the message can be improved, as I have been searching and do not understand it myself.
    – modulitos
    Aug 31, 2015 at 0:17
  • I think I will contact them at [email protected]
    – modulitos
    Aug 31, 2015 at 0:23
  • Your example works OK on orgmode 8.2.10. However, there is an @III reference in a table with only 2 hlines. Try substituting @III by @>, which refers to the last row.
    – Juancho
    Aug 31, 2015 at 0:49
  • 1
    Too bad the error message didn't say something like @Juancho said: "There is an @III reference in a table with only 2 hlines". ;-)
    – Drew
    Aug 31, 2015 at 4:47

2 Answers 2

5

When I change the formula to the one below:

#+TBLFM: @2$9..@-1$9=vsum($2..$8);%.2f;::@>$2..@>$9='(format "%3.2f" (apply '+ '(@2..@-1)));N;

It works! Basically, I had to find a workaround from using the hline relative references I II and III.

UPDATE

I just heard back from the org-mode team, and here is their response:

This is a known limitation: hline relative references are not allowed on the left hand side of a formula. The error message you get should be explicit.

After this clarification, the error message makes sense!

So, to re-introduce the hline references on the right side of my assignments would look like this:

#+TBLFM: @2$9..@-1$9=vsum($2..$8);%.2f;::@>$2..@>$9='(format "%3.2f" (apply '+ '(@I..@II)));N;
2
  • Hm, inspite of the info from the org-mode team org-table-get-range in org-table-expand-lhs-ranges should expand the range with relative hline-references on the left-hand side. (This is valid for org-mode 8.2.10 shipped with cygwin.) I tried it and it works.
    – Tobias
    Dec 30, 2015 at 12:25
  • The source code at orgmode.org/w/?p=org-mode.git;a=blob_plain;f=lisp/… has changed considerably but it seems that the essential lines are still in there. org-table-recalculate calls org-table-expand-lhs-ranges which calls org-table-get-range in turn.
    – Tobias
    Dec 30, 2015 at 12:38
4

As a workaround for the use of an hline-relative LHS formulas for in-table subtotals. I had the same problem as the OP, but found a reasonably flexible workaround using named fields. MWE:

|   | Breakfast                  |      Price |
|---+----------------------------+------------|
|   | Spam, eggs, and spam       |       2.35 |
|   | Spam, spam, eggs, and spam |       2.85 |
|---+----------------------------+------------|
|   | Breakfast Menu Total       |        5.2 |
| ^ |                            | bkfst_totl |
|---+----------------------------+------------|
|   | Lunch                      |      Price |
|---+----------------------------+------------|
|   | Spam sandwich              |       4.75 |
|   | Spam chunk                 |       3.50 |
|---+----------------------------+------------|
|   | Lunch Menu Total           |       8.25 |
| ^ |                            | lunch_totl |
|---+----------------------------+------------|
|   | Total                      |      13.45 |
#+TBLFM: $bkfst_totl=vsum(@I..@II) :: $lunch_totl=vsum(@IIII..IIIII) :: @>$>=$bkfst_totl+$lunch_totl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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