{"id":13678983,"url":"https://github.com/seburbandev/obsidian-dataview-cheatsheet","last_synced_at":"2025-04-29T16:30:35.963Z","repository":{"id":186098998,"uuid":"674622634","full_name":"seburbandev/obsidian-dataview-cheatsheet","owner":"seburbandev","description":"This cheatsheet provides a handy reference guide for writing powerful queries using the dataview plugin in Obsidian.","archived":false,"fork":false,"pushed_at":"2024-10-03T21:26:32.000Z","size":10,"stargazers_count":42,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-11T21:38:08.500Z","etag":null,"topics":["cheatsheet","dataview","dql","guide","obsidian","obsidian-md","query","reference","wiki"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seburbandev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-04T11:48:40.000Z","updated_at":"2024-11-09T18:02:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"601c6882-9556-483d-bfa7-3bacf010280c","html_url":"https://github.com/seburbandev/obsidian-dataview-cheatsheet","commit_stats":null,"previous_names":["seburbandev/obsidian-dataview-cheatsheet"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seburbandev%2Fobsidian-dataview-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seburbandev%2Fobsidian-dataview-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seburbandev%2Fobsidian-dataview-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seburbandev%2Fobsidian-dataview-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seburbandev","download_url":"https://codeload.github.com/seburbandev/obsidian-dataview-cheatsheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251540019,"owners_count":21605831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","dataview","dql","guide","obsidian","obsidian-md","query","reference","wiki"],"created_at":"2024-08-02T13:01:00.543Z","updated_at":"2025-04-29T16:30:35.957Z","avatar_url":"https://github.com/seburbandev.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Summary\n\nThis cheatsheet provides a handy reference guide for writing queries using \n**Dataview Query Language** (**DQL**) in the [dataview][dataview] plugin for \n[Obsidian.md][obsidian] note-taking app.\n\n# How to use this\n\nI recommend copying this file and including it in your Obsidian vault for easy \nreference. In this way, you can access the cheatsheet by pulling up the file \nor searching in your vault for a specific command.\n\nStar and fork this repository to see updates and pull them when more examples \nare added or the list of commands is expanded.\n\n# Table of Contents\n\n- [Query Commands](#query-cheatsheet)\n  - [LIST](#list)\n    - [Simple List](#simple-list)\n\t- [Table](#table)\n- [Data Commands](#data-commands)\n\t- [FROM](#from)\n\t\t- [Tags](#tags)\n\t\t- [Single Files](#single-files)\n\t\t- [Folders](#folders)\n\t\t- [Excluding Notes](#excluding-notes)\n\t\t\t- [Excluding notes with a specific tag](#excluding-notes-with-a-specific-tag)\n\t\t\t- [Excluding notes from a specific folder](#excluding-notes-from-a-specific-folder)\n\t\t- [Chaining Resources](#chaining-resources)\n\t\t\t- [AND operator](#and)\n\t\t\t- [OR operator](#or)\n\t- [WHERE](#where)\n\t\t- [WHERE property is NOT empty](#where-property-is-not-empty)\n\t\t- [WHERE property is equal to something](#where-property-is-equal-to-something)\n\t- [SORT](#sort)\n\t- [GROUP BY](#group-by)\n\t\t- [GROUP BY category](#group-by-category)\n\t- [FLATTEN](#flatten)\n\t\t- [Multiple properties displayed in its own row](#multiple-properties-displayed-in-its-own-row)\n\t- [Limit results in query](#limit-results-in-query)\n\t- [Extras](#extras)\n\t\t- [Bool property to custom display value](#bool-property-to-custom-display-value)\n- [Metadata Reference](#metadata-reference)\n\t- [JSON](#json)\n\t- [YAML](#yaml)\n\n# Query Cheatsheet\n\n## LIST\n\n### Simple List\n\n```sql\nLIST\nFROM\n  \u003ctag-name\u003e\n```\n\nExample\n\n```sql\nLIST\nFROM\n  #library\n```\n\n## Table\n\n```sql\nTABLE\n  Title\n  Author\nFROM\n  #library\n```\n\n[Back to Contents](#table-of-contents)\n\n# Data Commands\n\n- [FROM](#from)\n- [WHERE](#where)\n- [SORT](#sort)\n- [GROUP BY](#group-by)\n- [FLATTEN](#flatten)\n- [LIMIT](#limit)\n\n## FROM\nSelecting from different sources such as;\n\n### Tags\n\n`FROM #tag`\n\nExample\n\n```sql\nTABLE\n  file.cday as \"Created Date\"\nFROM\n  #my-tag\n```\n### Single Files\n\n`FROM \"path/to/file-name\"`\n\nExample\n\n```sql\nTABLE\n  file.cday as \"Created Date\"\nFROM\n  \"TopFolder/SubFolder/my-file-name\"\n```\n### Folders\n\n`FROM \"folder-name\"`\n\nExample\n\n```sql\nTABLE\n  file.cday as \"Created Date\"\nFROM\n  \"my-folder-name\"\n```\n\n### Excluding Notes\n\n#### Excluding notes with a specific tag\n\n`!#tag-name`\n\nExample\n\n```sql\nTABLE\n  Title,\n  Rating,\n  Seen,\n  SeenDate as \"Seen on\"\nFROM\n  #movie AND !#template\n```\n\nThe above example will return all notes with a tag `#movie` but exclude notes \nwith a tag `#template`. This is handy if you have a note with pre-populated \ntags but it's only used as a template so you don't want to see it in your \ntable view.\n\n#### Excluding notes from a specific folder\n\n`FROM #tag AND !\"FolderName\"`\n\nExample\n\n```sql\nTABLE\n  Title,\n  Rating,\n  Seen,\n  SeenDate as \"Seen on\"\nFROM\n  #movie AND !\"TemplatesFolder\"\n```\n\nBy including `!\"FolderName\"` we specify that we do not want to return any \nmatches if the are located in the specified folder.\n\n### Chaining Resources\n\nYou can fine tune query parameters utilizing the `AND` and `OR` operators\n\n#### AND\nThe `AND` operator queries notes that meet all criteria included in the query:\n\n```sql\nTABLE\n  Title,\n  Author,\n  Publication\nFROM\n  \"Books\" AND \"Magazines\"\n```\n\nUsing in conjunction with exclusion:\n\n```sql\nTABLE\n  Title,\n  Author,\n  Publication\nFROM\n  \"Books\" AND \"Books/assets\"\n```\n\n#### OR\nThe `OR` operator queries notes that meet any of the provided criteria:\n\n```sql\nTABLE\n  Title,\n  Author,\n  Publication\nFROM\n  #horror OR #comedy\n```\n\nUsing in conjunction with exclusion:\n\n```sql\nTABLE\n  Title\n  Author\n  Publication\nFROM\n  #horror OR #comedy AND !\"Books/assets\"\n```\n\n[Back to Contents](#table-of-contents)\n\n## WHERE\nExamples of queries containing WHERE clause.\n\n### WHERE property is NOT empty\n\n```sql\nWHERE\n  \u003cproperty-name\u003e\n```\n\nExample\n\n```sql\nTABLE\n  file.cday as \"Created\",\n  Category\nFROM\n  #books\nSORT\n  file.cday\nWHERE\n  Category\n```\n\nThe above example ensures to show only results where the meta-data 'Category' is not empty.\n\n### WHERE property is equal to something\n\n```sql\nWHERE\n  \u003cstring-property-name\u003e = \"my-value\"\n```\n\n```sql\nWHERE\n  \u003cdigit-property-name\u003e = 123\n```\n\nExamples\n\n```sql\nLIST\nWHERE\n  category = \"my-value\"\n```\n\n```sql\nLIST\nWHERE\n  digitProperty = 123\n```\n\n[Back to Contents](#table-of-contents)\n\n## SORT\nDataview offers simple ways to sort results. The most simplistic is by some \nproperty in ascending (asc) or descending (desc) order:\n\n```sql\nTABLE\n  Title,\n  Author,\n  Published,\n  Year\nFROM\n  #library\nSORT\n  Year asc\n```\n\nThis should serve well for most use-cases. More complex sorting mechanisms \nwill added here at a later time.\n\n[Back to Contents](#table-of-contents)\n\n## GROUP BY\nThe simplest method is to group by some property included in your frontmatter:\n\n```sql\nGROUP BY\n  \u003cproperty-name\u003e\n```\n\nGroup by category in a table:\n\n```sql\nTABLE \n  rows.file.name as \"File\"\nWHERE\n  category\nGROUP BY\n  category\n```\n\nGroup by category in a list:\n\n```sql\nLIST\n  rows.file.name\nWHERE\n  category = \"first-category\"\nGROUP BY\n  category\n```\n\nNOTE: When using `GROUP BY`, the structure of the results changes. Instead of \ndirectly accessing `file.name`, you must use the `rows` property to access the \nfile properties within each group. This is because results are now grouped \ninto rows based on the `GROUP BY` field.\n\n[Back to Contents](#table-of-contents)\n\n## FLATTEN\nUse `FLATTEN` to display multiple properties in a single row\n\n```sql\nFLATTEN\n  \u003cproperty-name\u003e\n```\n\nCode example:\n\n```sql\nTABLE\n  Title,\n  Action\nFLATTEN\n  Action\n```\n\nResult example:\n\n| File Name | Created | Action        |\n| --------- | ------- | ------------- |\n| Note 1    | July    | Action name 1 |\n| Note 1    | July    | Action name 2 |\n| Note 2    | August  | My Action 123 |\n| Note 2    | August  | Hello World   |\n\n[Back to Contents](#table-of-contents)\n\n## LIMIT\nYou can limit the results in a query:\n\n```sql\nLIMIT\n  \u003cnumerical-value\u003e\n```\n\nExample:\n\n```sql\nTABLE\n  Title,\n  Rating\nWHERE\n  Rating \u003e 3\nLIMIT\n  10\n```\n\n## Extras\n\n### Bool property to custom display value\nDataview provides options on how to display various forms of data. For \nexample, Booleans can be displayed as Yes/No instead of True/False:\n\n```js\nCHOICE(\u003cbool-property\u003e, \"Yes\", \"No\") as \"custom-name\"\n```\n\nExample\n\n```sql\nTABLE\n  Author as \"Author\",\n  choice(read, \"Yes\", \"No\") as \"Read\",\nFROM\n  \"Books\"\n```\n\n[Back to Contents](#table-of-contents)\n\n# Metadata Reference\n\nObsidian allows YAML and JSON for metadata.\n\n## JSON\n\nJSON\n\n```\n{\n  \"Author\": \"Author Name\",\n  \"Genre\": \"Fiction\",\n  \"DateRead\": \"2022-06-01\",\n  \"Read\": false,\n  \"Tags\": [\n    \"Mind-blowing\",\n    \"Interesting\",\n    \"Science\"\n  ]\n}\n```\n\n## YAML\n\nYAML\n\n```\nAuthor: Author Name\nGenre: Fiction\nDateRead: '2022-06-01'\nRead: false\nTags:\n- Mind-blowing\n- Interesting\n- Science\n```\n\n\u003c!-- links --\u003e\n[obsidian]: https://obsidian.md\n[dataview]: https://github.com/blacksmithgu/obsidian-dataview\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseburbandev%2Fobsidian-dataview-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseburbandev%2Fobsidian-dataview-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseburbandev%2Fobsidian-dataview-cheatsheet/lists"}