Get Dataview Table
🚨 Working with Dataview actions requires the Dataview community plugin.
This action queries Dataview and returns the results of a DQL table query as a nested list of strings, i.e. a list of list(s) of strings.
Dataview is an advanced topic that opens up a lot of possibilities for making sense of your notes and data. For information about DQL (Dataview Query Language), please see the related documentation on the Dataview site.
Construct your queries directly in Obsidian and once you're happy with it, copy them into the action — you will save some time this way as the DQL debugging notices and error messages are more readable in Obsidian itself.
Please note: The examples will not explain the syntax of DQL (because the official documentation already does that well).
In my Obsidian note there is this DV query to get a table of notes. These notes contact details of people. I want the fields
WHERE contact_id != NULL
Outside of the editor mode, the result is a table:
|Bella Belle||+49 345 67890||[email protected]|
|Dotti Dottirsdottir||+49 12 345678||[email protected]|
|Gunnar Gunnarssonsson||+49 2345678922222222||[email protected]|
(In Obsidian's Reading mode, the first column of the results is always linked to the related note. It just isn't here.)
When the query is executed, Dataview constructs a list for each result row. By default, the first field in each row is an Obsidian link. The following fields are the additional fields listed in the query, in this case,
[ "[[Contacts/Bella Belle.md|Bella Belle]]", "+49 345 67890", "[email protected]" ],
[ "[[Contacts/Dotti Dottirsdottir.md|Dotti Dottirsdottir]]", "+49 12 345678", "[email protected]" ],
[ "[[Contacts/Gunnar Gunnarssonsson.md|Gunnar Gunnarssonsson]]", "+49 2345678922222222", "[email protected]" ]
And that is exactly what this action will return: a list of table rows, i.e. a list of a list of strings.
Each table row in a result is returned in the form of a Dataview Table Row object. This object has a property "Columns" — which in itself is a list of strings, i.e. this row's fields.
See this screenshot / diagram on how you would access each table row's first field (note link) and second field (phone number):
If you plan to work a lot with this Dataview action, I recommend checking out the various list-related actions from Sindre Sorhus's excellent Actions app.