Skip to main content
2 of 2
added 1 character in body
Tobias
  • 33.7k
  • 1
  • 38
  • 78

I assume that every project has its own file and you want to sort w.r.t. the project time.

You can apply a filter to your table and sort the filtered result.

In the following I give an example of a possible adaption of one of the filters at https://emacs.stackexchange.com/a/20137/2370 for your case.

Notes:

  • The example does not sort the original table but creates a new one which you can sort. You have to decide whether it serves your purpose or not.
  • I added the name myclock to the clocktable
  • I filtered the rows with *File time* in the second column of your clocktable
  • You can apply the source code block by clicking C-c C-c on #+BEGIN_SRC
  • I already applied the sorting with org-table-sort-lines with sorting type N to the resulting filtered table.
#+BEGIN: clocktable :maxlevel 2 :block thisweek :link t :formula % :scope agenda-with-archives :step day :fileskip 0
#+NAME: myclock
| File           | Headline         | Time   |     % |
|----------------+------------------+--------+-------|
|                | ALL *Total time* | *5:04* | 100.0 |
|----------------+------------------+--------+-------|
| emacs.org      | *File time*      | *0:31* |  10.2 |
|                | Emacs            | 0:31   |  10.2 |
|----------------+------------------+--------+-------|
| project1.org   | *File time*      | *1:40* |  32.9 |
|                | Task1            | 1:40   |  32.9 |
|----------------+------------------+--------+-------|
| project2.org   | *File time*      | *2:40* |  52.6 |
|                | TaskA            | 2:40   |  52.6 |
|----------------+------------------+--------+-------|
| project3.org   | *File time*      | *0:13* |   4.3 |
|                | Task             | 0:13   |   4.3 |

#+NAME: table-filter
#+BEGIN_SRC emacs-lisp :var tbl=myclock val="*File time*" col=2
(cl-loop for row in tbl
         if (equal (nth (1- col) row) val)
         collect row into newtbl
         finally return newtbl)
#+END_SRC

#+RESULTS: table-filter
| project2.org | *File time* | *2:40* | 52.6 |
| project1.org | *File time* | *1:40* | 32.9 |
| emacs.org    | *File time* | *0:31* | 10.2 |
| project3.org | *File time* | *0:13* |  4.3 |
Tobias
  • 33.7k
  • 1
  • 38
  • 78