Dataview Query Examples
This note contains examples of useful Dataview queries that you can copy and adapt for your own dashboards.
Basic Queries
Simple Table
TABLE
field1 as "Column 1",
field2 as "Column 2"
FROM "path/to/folder"
SORT field1 DESCList View
LIST
FROM "path/to/folder"
WHERE conditionTask View
TASK
FROM "path/to/folder"
WHERE !completedAdvanced Queries
Grouping Data
TABLE rows.field1 as "Field 1"
FROM "path/to/folder"
GROUP BY field2 as "Group"Calendar View
CALENDAR file.day
FROM "Daily"Calculations
TABLE
length(rows) as "Count",
sum(rows.number_field) as "Sum",
average(rows.number_field) as "Average"
FROM "path/to/folder"
GROUP BY categoryDate Filtering
TABLE date as "Date"
FROM "path/to/folder"
WHERE date >= date(today) - dur(1 week)Task Progress
TABLE
length(filter(file.tasks.completed, (t) => t = true)) + " / " + length(file.tasks) as "Completed",
round(length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks) * 100) + "%" as "Progress"
FROM "path/to/folder"
WHERE length(file.tasks) > 0Query By Metadata
By Tags
TABLE
FROM #tag1 and #tag2By YAML Property
TABLE
FROM "path/to/folder"
WHERE property = "value"By File Path
TABLE
FROM "path/to/folder" OR "another/path"Embedding and Formatting
Inline Field
INLINE
FROM "path/to/folder"Custom Formatting
TABLE
"<span style='color: red'>" + field + "</span>" as "Styled Field"
FROM "path/to/folder"Embedding Links
TABLE
"[[" + file.name + "]]" as "Link"
FROM "path/to/folder"Common Use Cases
Recent Notes
TABLE file.mtime as "Last Modified"
WHERE file.mtime > date(today) - dur(1 week)
SORT file.mtime DESCReading List
TABLE
author as "Author",
(status = "completed" ? "✅" : "📖") as "Status"
FROM "03-Resources"
WHERE contains(tags, "book")
SORT status ASC, file.mtime DESCProject Status Overview
TABLE
status as "Status",
started as "Started",
round(length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks) * 100) + "%" as "Progress"
FROM "01-Projects"
WHERE length(file.tasks) > 0
SORT status ASC, file.mtime DESCDaily Notes Summary
TABLE
dateformat(file.day, "ccc, MMM dd") as "Date",
file.outlinks as "Links"
FROM "Daily"
SORT file.day DESC
LIMIT 7Related Notes By Tag
LIST
FROM ""
WHERE contains(tags, this.file.tags)
AND file.name != this.file.nameTips for Effective Queries
- Start simple: Begin with basic queries and gradually add complexity
- Use aliases: Rename columns with
as "New Name"for readability - Test incrementally: Add one condition at a time when building complex queries
- Use comments: Add comments above queries to explain what they do
- Optimize performance: Limit results and avoid unnecessary calculations for large vaults
- Be specific: Use precise paths and conditions to get exactly what you need