Evan Harmon - Memex

Obsidian DataView Plugin

#remember Manual adjustment of Dataview table columns

?? 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.  

Fields

In-note

exampleField:: exampleValue

Inline

From [author:: Edgar Allan Poe], written in (published:: 1845)

Inline and don't render

This will not show the (longKeyIDontNeedWhenReading:: key).

Type

TABLE
LIST
TASK
CALENDAR

CALENDAR file.day
FLATTEN all(map(file.tasks, (x) => x.completed)) AS "allCompleted"
WHERE !allCompleted

FROM

TAG
FOLDER
links

  • To obtain all pages which link to note, use note
  • outgoing()
    Files
  • You can select from a specific file by specifying it's full path: "folder/File".

Filter

WHERE

Functions

Functions - Dataview
contains(object|list|string, value)
outgoing()
lower()
replace()
list()
date()
dur()
string()
link()
embed()
elink()
Numeric

  • sum()

Boolean

  • and
  • or
  • !

Negate a Source

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".

File Object

  • Metadata on Pages - Dataview
    Field Name Data Type Description
    file.name Text The file name as seen in Obsidians sidebar.
    file.folder Text The path of the folder this file belongs to.
    file.path Text The full file path, including the files name.
    file.ext Text The extension of the file type; generally md.
    file.link Link A link to the file.
    file.size Number The size (in bytes) of the file.
    file.ctime Date with Time The date that the file was created.
    file.cday Date The date that the file was created.
    file.mtime Date with Time The date that the file was last modified.
    file.mday Date The date that the file was last modified.
    file.tags List A list of all unique tags in the note. Subtags are broken down by each level, so #Tag/1/A will be stored in the list as [#Tag, #Tag/1, #Tag/1/A].
    file.etags List A list of all explicit tags in the note; unlike file.tags, does not break subtags down, i.e. [#Tag/1/A]
    file.inlinks List A list of all incoming links to this file, meaning all files that contain a link to this file.
    file.outlinks List A list of all outgoing links from this file, meaning all links the file contains.
    file.aliases List A list of all aliases for the note as defined via the YAML frontmatter.
    file.tasks List A list of all tasks (I.e., | [ ] some task) in this file.
    file.lists List A list of all list elements in the file (including tasks); these elements are effectively tasks and can be rendered in task views.
    file.frontmatter List Contains the raw values of all frontmatter in form of key | value text values; mainly useful for checking raw frontmatter values or for dynamically listing frontmatter keys.
    file.day Date Only available if the file has a date inside its file name (of form yyyy-mm-dd or yyyymmdd), or has a Date field/inline field.
    file.starred Boolean if this file has been starred via the Obsidian Core Plugin "Starred Files".

Reference current/active note's metadata/fields

test: `= this.url`

Good way to do order of operations () on WHERE

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)
  )
)

Fields with the same name as keywords (like "from", "where")?

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" */

Examples

←←← Other Tasks Nearby →→→

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

Date Calculations

departure:: 2022-10-07T15:15
length of travel:: 1 day, 3 hours

Arrival: = this.departure + this.length-of-travel

List pages that have this author

LIST
FROM ""
WHERE contains(by, "Paul")
LIST
FROM ""
WHERE by = [[Albert Camus]]

Contains both tags

TABLE file.date
FROM ""
WHERE contains(file.tags, "Personal") AND
contains(file.tags, "Project")

KCDC 2022 Talks

table name, time, rating
from "_Stream/KCDC2022"
sort time, rating desc

Bullet Lists Containing Tag

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")

Task Progress Bar

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

contains() With lists

WHERE contains(as, link("Philosopher")) = true

Obsidian DataView Plugin
Interactive graph
On this page
Obsidian DataView Plugin
Fields
In-note
Inline
Inline and don't render
Type
FROM
Filter
Functions
Boolean
Negate a Source
File Object
Reference current/active note's metadata/fields
Good way to do order of operations () on WHERE
Fields with the same name as keywords (like "from", "where")?
Examples
←←← Other Tasks Nearby →→→
Date Calculations
List pages that have this author
Quotes > My Favorite Quotes (Excerpts) Dataview
Contains both tags
KCDC 2022 Talks
Bullet Lists Containing Tag
Task Progress Bar
contains() With lists