Skip to content

This cheatsheet provides a handy reference guide for writing powerful queries using the dataview plugin in Obsidian.

Notifications You must be signed in to change notification settings

seburbandev/obsidian-dataview-cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 

Repository files navigation

Summary

This cheatsheet provides a handy reference guide for writing queries using Dataview Query Language (DQL) in the dataview plugin for Obsidian.md note-taking app.

How to use this

Use it however you like but I would suggest you copy this file and simply paste it into your own Obsidian vault. You can then reference this from within your own vault by either accessing the file or searching in your vault for specific command.

Star and follow this repository if you want to be updated when I add more examples to this list.

Table of Contents

Query Cheatsheet

LIST

Simple List

LIST FROM <tag-name>

Example

LIST
FROM
#games

Table

TABLE
  Title
FROM
  #tagName

Data Commands

  • FROM
  • WHERE
  • SORT (to do)
  • GROUP BY (to do)
  • FLATTEN
  • LIMIT

FROM

Selecting from different sources such as;

Tags

FROM #tag

Example

TABLE
  file.cday as "Created Date"
FROM
  #my-tag

Excluding notes with a specific tag

!#tag-name

Example

TABLE
  Title,
  Rating,
  Seen,
  SeenDate as "Seen on"
FROM
  #movie AND !#template

The above example will return all notes with a tag #movie but exclude notes with a tag #template. This is handy if you have a note with pre-populated tags but it's only used as a template so you don't want to see it in your table view.

Excluding notes from a specific folder

FROM #tag AND !"FolderName"

Example

TABLE
  Title,
  Rating,
  Seen,
  SeenDate as "Seen on"
FROM
  #movie AND !"TemplatesFolder"

By including !"FolderName" we specify that we do not want to return any matches if the are located in the specified folder.

Folders

FROM "folder-name"

Example

TABLE
  file.cday as "Created Date"
FROM
  "my-folder-name"

Single Files

FROM "path/to/file-name"

Example

TABLE
  file.cday as "Created Date"
FROM
  "TopFolder/SubFolder/my-file-name"

GROUP BY

GROUP BY category

GROUP BY <property-name>

Examples

TABLE 
rows.file.name as "File"
WHERE category
GROUP BY  category
LIST
rows.file.name
WHERE
category = "first-category"
GROUP BY category

NOTE: When using group by, the structure of the results changes. Instead of directly accessing file.name, you must use the rows property to access the file properties within each group. This is because results are now grouped into rows based on the group by field.

WHERE

Examples of queries containing WHERE clause.

WHERE property is NOT empty

WHERE <property-name>

Example

TABLE
  file.cday as "Created",
  Category
FROM
  #books
SORT
  file.cday
WHERE
  Category

The above example ensures to show only results where the meta-data 'Category' is not empty.

WHERE property is equal to something

WHERE <string-property-name> = "my-value"
WHERE <digit-property-name> = 123

Examples

LIST
WHERE
Category = "my-value"
LIST
WHERE
DigitProperty = 123

FLATTEN

Multiple properties displayed in its own row

FLATTEN <property-name>

Code example:

TABLE
  Title,
  Action
FLATTEN Action

Result example:

File Name Created Action
Note 1 July Action name 1
Note 1 July Action name 2
Note 2 August My Action 123
Note 2 August Hello World

Bool property to custom display value

Display Yes/No instead of True/False on bool properties

Snippet

CHOICE(<bool-property>, "Yes", "No") as "custom-name"

Example

TABLE
  Author as "Author",
  choice(read, "Yes", "No") as "Read",
FROM
  "Books"

Limit results in query

LIMIT 10

Example:

TABLE
  Title,
  Rating
WHERE
  Rating > 3
LIMIT 10

Meta Data Examples

Obsidian allows YAML and JSON for metadata.

JSON

JSON

{
  "Author": "Author Name",
  "Genre": "Fiction",
  "DateRead": "2022-06-01",
  "Read": false,
  "Tags": [
    "Mind-blowing",
    "Interesting",
    "Science"
  ]
}

YAML

YAML

Author: Author Name
Genre: Fiction
DateRead: '2022-06-01'
Read: false
Tags:
- Mind-blowing
- Interesting
- Science

About

This cheatsheet provides a handy reference guide for writing powerful queries using the dataview plugin in Obsidian.

Topics

Resources

Stars

Watchers

Forks