Obsidian Dataview Cheatsheet
Shamelessly stolen from here
Table of Contents
- LIST
- Data Commands
- Meta Data Examples
Query Cheatsheet
LIST
Simple List
LIST FROM <tag-name>Example
LIST
FROM
#gamesTable
TABLE
Title
FROM
#tagNameData 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-tagExcluding Notes With a Specific Tag
!#tag-name
Example
TABLE
Title,
Rating,
Seen,
SeenDate as "Seen on"
FROM
#movie AND !#templateThe 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 categoryLIST
rows.file.name
WHERE
category = "first-category"
GROUP BY categoryNOTE: 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
CategoryThe 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> = 123Examples
LIST
WHERE
Category = "my-value"LIST
WHERE
DigitProperty = 123FLATTEN
Multiple Properties Displayed in Its Own Row
FLATTEN <property-name>Code example:
TABLE
Title,
Action
FLATTEN ActionResult 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 10Example:
TABLE
Title,
Rating
WHERE
Rating > 3
LIMIT 10Meta 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