8.4.2 The clock table
Org mode can produce quite complex reports based on the time clocking information. Such a report is called a clock table, because it is formatted as one or several Org tables.
org-clock-reportβ
Insert or update a clock table. When called with a prefix argument, jump to the first clock table in the current document and update it. The clock table includes archived trees.
This command can be invoked by calling org-dynamic-block-insert-dblock (C-c C-x x) and selecting βclocktable" (see Dynamic Blocks).
C-c C-c or C-c C-x C-u (org-dblock-update)β
Update dynamic block at point. Point needs to be in the βBEGINβ line of the dynamic block.
C-u C-c C-x C-uβ
Update all dynamic blocks (see Dynamic Blocks). This is useful if you have several clock table blocks in a buffer.
S-LEFTβ
S-RIGHT (org-clocktable-try-shift)β
Shift the current β:blockβ interval and update the table. Point needs to be in the β#+BEGIN: clocktableβ line for this command. If β:blockβ is βtodayβ, it is shifted to βtoday-1β, etc.
Here is an example of the frame for a clock table as it is inserted into the buffer by org-clock-report:
#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
#+END: clocktable
The β#+BEGINβ line contains options to define the scope, structure, and formatting of the report. Defaults for all these options can be configured in the variable org-clocktable-defaults.
First there are options that determine which clock entries are to be selected:
β:maxlevelββ
Maximum level depth to which times are listed in the table. Clocks at deeper levels are summed into the upper level.
β:scopeββ
The scope to consider. This can be any of the following:
| β nilβ | the current buffer or narrowed region | 
| β fileβ | the full current buffer | 
| β subtreeβ | the subtree where the clocktable is located | 
| β treeNβ | the surrounding level N tree, for example β tree3β | 
| β treeβ | the surrounding level 1 tree | 
| β agendaβ | all agenda files | 
| β ("file" ...)β | scan these files | 
| β FUNCTIONβ | scan files returned by calling FUNCTIONwith no argument | 
| β file-with-archivesβ | current file and its archives | 
| β agenda-with-archivesβ | all agenda files, including archives | 
β:blockββ
The time block to consider. This block is specified either absolutely, or relative to the current time and may be any of these formats:
| β 2007-12-31β | New year eve 2007 | 
| β 2007-12β | December 2007 | 
| β 2007-W50β | ISO-week 50 in 2007 | 
| β 2007-Q2β | 2nd quarter in 2007 | 
| β 2007β | the year 2007 | 
| β todayβ, βyesterdayβ, βtoday-Nβ | a relative day | 
| β thisweekβ, βlastweekβ, βthisweek-Nβ | a relative week | 
| β thismonthβ, βlastmonthβ, βthismonth-Nβ | a relative month | 
| β thisyearβ, βlastyearβ, βthisyear-Nβ | a relative year | 
| β untilnowβ1 | all clocked time ever | 
When this option is not set, Org falls back to the value in org-clock-display-default-range, which defaults to the current year.
Use S-LEFT or S-RIGHT to shift the time interval.
β:tstartββ
A time string specifying when to start considering times. Relative times like β"<-2w>"β can also be used. See Matching tags and properties for relative time syntax.
β:tendββ
A time string specifying when to stop considering times. Relative times like β"<now>"β can also be used. See Matching tags and properties for relative time syntax.
β:wstartββ
The starting day of the week. The default is 1 for Monday.
β:mstartββ
The starting day of the month. The default is 1 for the first.
β:stepββ
Set to βdayβ, βweekβ, βsemimonthβ, βmonthβ, or βyearβ to split the table into chunks. To use this, either β:blockβ, or β:tstartβ and β:tendβ are required.
β:stepskip0ββ
When non-nil, do not show steps that have zero time.
β:fileskip0ββ
When non-nil, do not show table sections from files which did not contribute.
β:matchββ
A tags match to select entries that should contribute. See Matching tags and properties for the match syntax.
Then there are options that determine the formatting of the table. There options are interpreted by the function org-clocktable-write-default, but you can specify your own function using the β:formatterβ parameter.
β:emphasizeββ
When non-nil, emphasize level one and level two items.
β:langββ
Language2 to use for descriptive cells like βTask".
β:linkββ
Link the item headlines in the table to their origins.
β:narrowββ
An integer to limit the width of the headline column in the Org table. If you write it like β50!β, then the headline is also shortened in export.
β:indentββ
Indent each headline field according to its level.
β:hidefilesββ
Hide the file column when multiple files are used to produce the table.
β:tcolumnsββ
Number of columns to be used for times. If this is smaller than β:maxlevelβ, lower levels are lumped into one column.
β:levelββ
Should a level number column be included?
β:sortββ
A cons cell containing the column to sort and a sorting type. E.g., β:sort (1 . ?a)β sorts the first column alphabetically.
β:compactββ
Abbreviation for β:level nil :indent t :narrow 40! :tcolumns 1β. All are overwritten except if there is an explicit β:narrowβ.
β:timestampββ
A timestamp for the entry, when available. Look for βSCHEDULEDβ, βDEADLINEβ, βTIMESTAMPβ and βTIMESTAMP_IAβ special properties (see Special Properties), in this order.
β:tagsββ
When this flag is non-nil, show the headlineβs tags.
β:propertiesββ
List of properties shown in the table. Each property gets its own column.
β:inherit-propsββ
When this flag is non-nil, the values for β:propertiesβ are inherited.
β:formulaββ
Content of a βTBLFMβ keyword to be added and evaluated. As a special case, β:formula %β adds a column with % time. If you do not specify a formula here, any existing formula below the clock table survives updates and is evaluated.
β:formatterββ
A function to format clock data and insert it into the buffer.
To get a clock summary of the current level 1 tree, for the current day, you could write:
#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
#+END: clocktable
To use a specific time range you could write3
#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
                    :tend "<2006-08-10 Thu 12:00>"
#+END: clocktable
A range starting a week ago and ending right now could be written as
#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
#+END: clocktable
A summary of the current subtree with % times would be
#+BEGIN: clocktable :scope subtree :link t :formula %
#+END: clocktable
A horizontally compact representation of everything clocked during last week would be
#+BEGIN: clocktable :scope agenda :block lastweek :compact t
#+END: clocktable