Skip to main content


Wrapping my brain around using #org-mode as a spreadsheet. Is there a way to pass a range of cells as a vector to a custom function? Ideally, I'd like to embed this function into the file itself. #emacs

bjb reshared this.

in reply to Jonathan Lamothe

I WANT TO SHOW YOU MY TOYS!

I just did my 2024 taxes in org-mode spreadsheets!

in reply to Shae Erisson

@Shae Erisson If there's a way you could show me this without doxxing yourself, I'd love to see it!
in reply to Jonathan Lamothe

Yeah, I'd love to show you! I keep meaning to write a blog post.

In summary, table references are updated when that table's cells are reordered.

If another table refers to a cell in this table, that reference is not updated when the cell moves.

You can name a field! I was able to decipher this confusing illustration after an hour of staring: orgmode.org/org.html#Advanced-…

I'd already decided to do each tax form as its own spreadsheet: gist.github.com/shapr/84e37fdf…

Does the gist help?

in reply to Jonathan Lamothe

Ahem, sorry about that excitement explosion.

Yes, you can call elisp functions, um, lemme find the reference

in reply to Jonathan Lamothe

Oh, as a vector? 🤔

Gosh I don't know about that.

orgmode.org/worg/org-tutorials…

That shows you how to define a column formula with elisp. I think think usual "vsum" and friends are vector operations from the emacs calculator, so it seems very likely?

in reply to Jonathan Lamothe

I gotta go to the bike shop, but my heuristic would be:

1. I know vsum works in org-mode spreadsheet formulas
2. I know the v stands for "vector"
3. Can I use that function's source to define my own vector operations?

I like to think the answer is YES. I am hopeful at least.

in reply to Shae Erisson

@Shae Erisson Ah, I hadn't thought about looking at the source for vsum to see how it works. Internally it's calcFunc-vsum right?
in reply to Shae Erisson

@Shae Erisson So, of appears that I can pass simple (single cell) references into raw elisp functions, but not ranges. I'll have to have a closer look at vsum as mentioned earlier to see if there's a solution there.
in reply to Jonathan Lamothe

I don't understand pivot tables, so I can't help.

What would this look like?

in reply to Shae Erisson

@Shae Erisson A pivot table essentially takes values from a source table and sorts them into buckets. Here's a simple example I built manually.
#+NAME: source
| Bill | Account  | Amount |
|------+----------+--------|
| foo  | chequing |  13.50 |
| bar  | savings  |  22.75 |
| baz  | chequing |   9.50 |
| quux | savings  |  11.15 |

#+NAME: pivot
| Account  | Total |
|----------+-------|
| chequing | 23.00 |
| savings  | 33.90 |
#+TBLFM: @2$2=remote(source,@2$3)+remote(source,@4$3);%1.2f::@3$2=remote(source,@3$3)+remote(source,@5$3);%1.2f
in reply to Jonathan Lamothe

Nice! I recently added pivottable functionality to #cfw but I don't think it would help you here.

It is since complete with transient menus and drilldown.

#cfw
in reply to hajovonta

I would be interested if you manage to read org tables as lisp lists. I haven't tried it yet, but I plan to do it occasionally, so cfw would get an org-table import/export. Currently it can do CSV.

This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.