aliases:
- Dataview
tags:
- Type/Tech/Platform/Obsidian
- area/tech/obsidian
- proto
- Type/Tech/Platform/Tool
- area/tech
- v/how-to
- remember
- Tag/1/A
- Tag
- Tag/1
publish: true
version: 1
dateCreated: 2023-03-16, 12:37
dateModified: 2024-03-01, 18:15
from:
- "[[Tech]]"
related:
- "[[Obsidian]]"
- "[[Obsidian Plugins]]"
- "[[Obsidian Templater Plugin]]"
contra:
to:
url:: DataView
docs:: Dataview
blacksmithgu/obsidian-dataview: A high-performance data index and query language over Markdown files, for https://obsidian.md/.
?? Best way I found is to rename the columns with a unicode ideographic space - U+3000 " ". So just add as many as you need to each column.
exampleField:: exampleValue
From [author:: Edgar Allan Poe], written in (published:: 1845)
This will not show the (longKeyIDontNeedWhenReading:: key).
TABLE
LIST
TASK
CALENDAR
CALENDAR file.day
FLATTEN all(map(file.tasks, (x) => x.completed)) AS "allCompleted"
WHERE !allCompleted
TAG
FOLDER
links
WHERE
Functions - Dataview
contains(object|list|string, value)
outgoing()
lower()
replace()
list()
date()
dur()
string()
link()
embed()
elink()
Numeric
You can also "negate" sources to obtain anything that does NOT match a source using -
:
-#tag
will exclude files which have the given tag.#tag and -"folder"
will only include files tagged #tag
which are NOT in "folder"
.test: `= this.url`
LIST
FROM "meetings" or "meetings/recurring"
WHERE
(
(
occurrence >= date(this.file.week_start)
AND
occurrence <= date(this.file.week_end)
)
OR
(
file.day >= date(this.file.week_start)
AND
file.day <= date(this.file.week_end)
)
)
Dataview provides a special "fake" field called row which can be indexed into to obtain fields which conflict with Dataview keywords:
row.from /* Same as "from" */
row.where /* Same as "where" */
Good for daily note e.g.
TASK
FROM "Time" AND -"-Meta"
WHERE date(file.name) >= date(this.file.name) - dur(5 days) AND
date(file.name) <= date(this.file.name) + dur(5 days) AND
file.name != dateformat(date(this.file.name), "yyyy-MM-dd") AND
!completed
SORT date desc
departure:: 2022-10-07T15:15
length of travel:: 1 day, 3 hours
Arrival: = this.departure + this.length-of-travel
LIST
FROM ""
WHERE contains(by, "Paul")
LIST
FROM ""
WHERE by = [[Albert Camus]]
TABLE file.date
FROM ""
WHERE contains(file.tags, "Personal") AND
contains(file.tags, "Project")
table name, time, rating
from "_Stream/KCDC2022"
sort time, rating desc
Not performant - can only do small sources or I should switch to requiring tasks or just using a regular query
LIST item.text
FROM "Personal"
FLATTEN file.lists as item
WHERE contains(item.text, "#question")
TABLE file.tasks.text, length(file.tasks.text) as Total, file.tasks.completed, filter(file.tasks.completed, (t) => t = true) as C, length(filter(file.tasks.completed, (t) => t = true)) AS Completed, (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 AS BB, "<progress value='" + (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 + "' max='100'></progress>" AS Progress
FROM "Professional"
WHERE file.tasks
WHERE contains(as, link("Philosopher")) = true