6

I would like to make a orgmode Clock report that groups tasks based on their category rather than file name alone. This would allow me to have fewer todo files to navigate around in.

I could not find anything in the clocktable report reference about this. Is it possible to have such reports? (or even make the agenda clock report group things by category?)

The closest I got so far is to set the :properties ("Effort" "CATEGORY") . This shows the category column, but doesn't group by it.

1 Answer 1

1

This is a really old question, but I needed something similar so I am putting this here in case someone needs it. I did this by defining a formatter that groups the categories.

(defun private/clocktable-formatter-group-by-prop (ipos tables params)
  (let* ((formatter (or org-clock-clocktable-formatter
                        'org-clocktable-write-default))
         (ht (make-hash-table :test 'equal))
         (total 0)
         (grouped
          (dolist (tt tables (sort (hash-table-keys ht)
                                   #'(lambda (x y) (string< x y))))
            (setq total (+ total (nth 1 tt)))
            (dolist (record (nth 2 tt))
              (let* ((lasttwo (last record 2))
                     (time (pop lasttwo))
                     (prop (cdr (car (car lasttwo))))
                     (prev (gethash prop ht 0)))
                (puthash prop (+ prev time) ht))
              ))
          )
         (newtable (mapcar (lambda (arg) (list 1 arg nil nil (gethash arg ht) nil)) grouped))
         (new-params (org-plist-delete params :properties)))
    (funcall formatter ipos (list (list nil total newtable)) new-params)))

Then I can use it like this

#+BEGIN: clocktable :scope file :properties ("CATEGORY") :formatter clocktable-formatter-group-by-prop
#+CAPTION: 
#+END:

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.