# Dataview plugin for Obsidian
The Dataview plugin for Obsidian enables querying, aggregating, filtering and sorting your notes in different ways (e.g., based on tags, location, metadata, etc), and creating lists, tables, as well as other representations.
The output of Dataview queries is dynamic, it updates all the time when you open notes containing queries.
Unfortunately, even if the query output contains links, those don't appear in the graph since those are not "real" Markdown links. Different plugins, such as the [[Dataview Serializer plugin for Obsidian]] that I have created, enable creating actual Markdown output (and links!).
## Examples
Find quotes corresponding to a specific author:
```javascript
LIST FROM #type/quote and [[<% tp.file.title %>]]
SORT file.name ASC
```
Find recently modified notes:
```javascript
$=dv.list(dv.pages('').sort(f=>f.file.mtime.ts,"desc").limit(5).file.link)
```
Find orphan notes:
```javascript
TABLE file.ctime AS "updated"
FROM "" WHERE length(file.inlinks) = 0
AND length(file.outlinks) = 0
AND length(file.tags) = 0
AND file.name != "Orphans"
SORT file.mtime desc
```
Find duplicate notes:
```javascript
// Reference: https://github.com/claremacrae/obsidian-experiments-plugin/issues/1#issuecomment-1139556976
function listFileNameIssues(dv) {
let pages = dv.pages();
let groups = pages.groupBy(p => p.file.name.toLowerCase());
for (let group of groups) {
let count = 0
for (let page of group.rows.sort(p => p.file.path, 'asc')) {
count += 1;
}
if (count === 1 ) {
continue;
}
for (let page of group.rows.sort(p => p.file.path, 'asc')) {
dv.paragraph(page.file.link + ': ' + page.file.path);
}
}
}
listFileNameIssues(dv);
```
Pick random notes:
```javascript
const limit = 10;
const notes = dv.pages().sort(() => Math.random()).slice (0, limit).map(note => note.file.link);
dv.list(notes);
```
Count the number of notes:
```javascript
$=dv.pages().length
```
## Example Vault
You can find an example vault full of Dataview queries here: https://s-blu.github.io/obsidian_dataview_example_vault. It is maintained [by the community](https://github.com/s-blu/obsidian_dataview_example_vault).
You can download the vault here and open it in Obsidian: https://github.com/s-blu/obsidian_dataview_example_vault/archive/refs/heads/master.zip
## References
- Documentation: https://blacksmithgu.github.io/obsidian-dataview/
- Source code: https://github.com/blacksmithgu/obsidian-dataview
- Easy to use query builder: https://s-blu.github.io/basic-dataview-query-builder/
- Cheatsheet: https://github.com/seburbandev/obsidian-dataview-cheatsheet
- Example snippets: https://github.com/Aetherinox/obsidian-dataview-snippets
## Related
- [[Dataview Serializer plugin for Obsidian]]
- [[Datacore plugin for Obsidian]]
- [[Obsidian Starter Kit]]
- [[Michael Brenan]]