Excel tables lets us show just the rows that have "July 2018" in a specific column, and hide the rest. Or to show "21st August 2017-30th August 2017, and also July 2018, and also all of 2019", and filter away the rest

How can we most easily do this with org-tables?

  • I doubt there is an easy way to do that (although of course it can be done: it's just a matter of programming...) But Org tables were never meant to take the place of a "real" spreadsheet: there are far too many features in the latter for Org mode to ever hope to emulate completely. – NickD Mar 22 '20 at 22:29

You can create an overlay that hides lines with (make-overlay (line-beginning-position) (1+ (line-end-position))) and (overlay-put ol 'invisible t).

The following Elisp Org formula hides the line with the element 21 in its first column. It just shows the principle and has much room for improvement. E.g., multiple evaluation of the org formula results in multiple overlapping overlays.

The lisp form is called for side-effect only therefore it just returns $1.

| 11 | 12 | 13 |
| 21 | 22 | 23 |
| 31 | 32 | 33 |
#+TBLFM: $1='(progn (when (equal $1 "21") (let ((ol (make-overlay (line-beginning-position) (1+ (line-end-position))))) (overlay-put ol 'invisible t))) $1)

I just use remove-overlays to remove the overlays when I want to.

For convenience I gave remove-overlays an interactive form:

(defun remove-overlays-interactive-form (&rest _args)
  "Make `remove-overlays' interactive.
Forward _ARGS to `remove-overlays'."
  (interactive (when (region-active-p)
         (list (region-beginning) (region-end)))))

(advice-add 'remove-overlays :before #'remove-overlays-interactive-form)

That way I only need to select a region - in our example the table - and run M-x remove-overlays RET.

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.