MBH
MBH

Reputation: 141

Is there any way to keep a running total of the amount of items for any given tag?

So I keep a phone log for work in org-mode. A new call comes in and I start a capture template which marks it as a TODO. When that item is completed, I marked it as DONE. I then add a tag if that phone call is related to a different department, :SALES: :ACCOUNTING: :SERVICE:

Can you think of a way to keep a running total of how many calls are tagged for the other departments? Ideally, it would be in the same Org file as a table.

Basically, I am trying to justify that our company now needs a receptionist. Any ideas?

Upvotes: 3

Views: 56

Answers (1)

Juancho
Juancho

Reputation: 7372

The following example is my interpretation of your question. It uses org-map-entries to search the buffer for tags, for each tag in a given list.

* DONE call 1                                                         :sales:
* DONE call 2                                                         :sales:
* DONE call 3                                                    :accounting:
* DONE call 4                                                         :sales:
* DONE call 5                                                         :sales:

* Summary

#+begin_src elisp :export results
  (mapcar (lambda (tag)
            (list tag (length (org-map-entries t tag nil))))
          '("accounting" "sales"))
#+end_src

#+RESULTS:
| accounting | 1 |
| sales      | 4 |

You can tweak the match strings for better filtering.

Upvotes: 5

Related Questions