Sort attribute tables

Attribute tables are a hidden feature in Roam that allows you to automatically create a table based on a attribute—which work the same as normal links and tags. The function will look for other attributes at the same level of the attribute you enter, which will be added as columns.

The shortcode to create an attribute table is as follows:

{{attr-table: [[Tag you wish to base your table on]]}}

By default, the attribute table items show in random order and you cannot sort. But, open source developer David Vargas has created a plugin that adds ascending and descending sort options.

Furthermore, with the sorting plugin it’s possible to choose what columns to include by nesting a Include Columns:: attribute underneath the attribute table, containing a comma-separated list of the columns you wish to include. For example:

Include Columns:: ---, Metadata, Highlights, Notes

Notice that the filter values don’t have brackets. The snippet above will only include the page title (---) where the attribute is located, plus the Metadata, Highlights and Notes attributes/tags that are on the same indentation level.

The full code to create an attribute table is as follows:

- {{attr-table: [[Tag you wish to base your table on]]}}
	- Include Columns:: ---. Metadata, Highlights, Notes

Click here to download the plugin and see more in-depth instructions.

Don’t know how to install a plugin? See these instruction in the knowledge base.

Was this helpful?