Dataview plugin snippet showcase

“THISWEEK” is the week number present in the “week” yaml field in the note where you place you query or is relative to really current week?

  1. If the first case: WHERE week = this.week
  2. If the second case, how you define your week number? By month or by year? By your table fields I deduce you use week of the year. In this case: WHERE week = date(today).weekyear

I am in the very early stages of trying to learn how to code so this may be a silly question. I’ve created a list of files in a folder sorted by category. Is there a way to have the file name as an internal link (eg [[name]]) so that it creates an outgoing link that would appear in graph view?

1 Like

To my knowledge there is no way to make the results from a dataview snippet/result to populate the graph view. This means your results from a dataview query indeed can create links to various files depending on your query, but that result will not show up the graph view.

I am guessing this is because the graph view literally reads your static files and populates based on links, tags etc that are all hard-coded in to those static files.

Dataview on the other hand does its calculations every time a particular file is loaded and that particular query is loaded, but also only then. The result isn’t “stored” somewhere.

If dataview were to be able to populate the graph each of the dataview queries would need to be run in ALL your files every time you opened a new file (to check if something, somewhere had changed). In large vaults this would be a massive calculation.

The only theoretical way around that would be if there somehow, somewhere, was a query caching function that made the query results semi-permanent so they could be read by the graph functionality. This, to my knowledge, does not exist.

Thanks! Works like a charm! :slightly_smiling_face:

How do you capture the sleep data in your daily note?

edit 16-01-2022: I have updated the templates on my GitHub, I’ll try and keep them up to date if any big changes. Please get in touch if you have other ideas or find any errors!

@Saorsa

  • I use #:notebook: and nested tags to indicate a journal entry
  • install “Banners” Plugin - It’s nice
  • install “Templeter” plugin - which will pull in all of the dates
  • install “Dataview” - you can see which inline fields I’m currently using.
    • in the weekly note, you will see roll ups from the week, and I do a review, and summarise it so I am tracking/learning from experience
  • QuickAdd plugin - allows you to assign a hotkey to capture a note in the journal on the go, and it will add it after the capture line

here is my daily note template

---
banner: https://cdn.wallpapersafari.com/8/5/cYaDFd.jpg
banner_x: 0.5
banner_y: 0.38
aliases: [<% tp.date.now("dddd, Do of MMMM YYYY", 0, tp.file.title, "YYYY-MM-DD") %>]
---
%% QuickAdd plugin - insert capture after this line %%
<%* if (tp.date.now("ddd") == "Sun") { %>- [ ] Do Weekly Review Note
- **Review Cycles**:: Weekly<%* } %>
<%* if (tp.date.now("D") == 1){ %>- [ ] Do Monthly Review Note  
- **Review Cycles**:: Monthly<%* } %>
<%* if (tp.date.now("MM-DD") == "01-01"){ %>- [ ] Do Yearly Note  
- **Review Cycles**:: Yearly<%* } %>
---
- **Top Notes**:: 
---
## Morning
- This month's focus:: `=this.month.theme`
- How did you **sleep**? 
	- **Sleep Hour**:: 
	- **Sleep Minute**:: 0
	- **Awake Hour**:: 
	- **Awake Minute**:: 0
	- *Calculate duration*: `=round(sum(24 - sum(this.file.link.sleep-hour + (this.file.link.sleep-minute / 60)) + sum(this.file.link.awake-hour + (this.file.link.awake-minute / 60))), 4)` hours
	- **Sleep Duration**:: 
	- **Sleep Comments**:: 
- Start the day and reflections
	- Make Bed:: 
	- Brush Teeth:: 
	- Clean one thing:: 
	- **Morning Gratitude**:: 
	- **Desired Outcome**:: 
	- **Plan Today**:: 
	- **Mindfulness**:: 
	- **Morning Pages**:: 
	- **Doing The Work**:: 
	- **Flashcards**:: 
	- Push up:: 

---
## 🌒 Evening Wind Down
- *Yesterday's To Improve*: `=[[<% tp.date.weekday("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]].to-improve`  
- *Today's Desired Outcome*: `=[[<% tp.file.title %>]].desired-outcome`  
- Evening Gratitude
	- **Wins**:: 
	- **Disappointments**:: 
	- **Evening Gratitude**:: 
	- **To Improve**:: 
	- Plan Tomorrow:: 

%%

###### Hidden Temporal Information
- #📓/☀️
- **Week**:: [[<%tp.date.now("YYYY-[W]ww", +0, tp.file.title, "YYYY-MM-DD")%>]]  
- **Month**:: [[<%tp.date.now("YYYY-MM", +0, tp.file.title, "YYYY-MM-DD")%>]]  

%%

Here is my weekly note template

##### Temporal Information
- #📓/7️⃣
- **Days**:: [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +0, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +1, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +2, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +3, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +4, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +5, tp.file.title, "YYYY-[W]ww") %>]]
	%% Create note on Sunday - days of the week include from Sunday last week to Saturday%%
- **Month**:: [[<%tp.date.now("YYYY-MM", +0, tp.file.title, "YYYY-[W]ww")%>]]  
- **Quarter**:: [[<% tp.date.now("YYYY-[Q]Q", +0, tp.file.title, "YYYY-[W]ww") %>]]
- **Year**:: [[<% tp.date.now("YYYY", +0, tp.file.title, "YYYY-[W]ww") %>]]

# <% tp.date.now("dddd Do of MMMM YYYY", +0, tp.file.title, "YYYY-[W]ww") %> to <% tp.date.now("dddd Do of MMMM YYYY", +6, tp.file.title, "YYYY-[W]ww") %>
## Review Past Week
###### Monthly Theme [[<% tp.date.now("YYYY-MM", +0, tp.file.title, "YYYY-[W]ww") %>]]: `=this.month.theme`
##### Review Guiding Principles - *quick skim of bullet points*
- ![[Guiding Principles Development - 2021-09#Guiding Principles]]

##### Sleep and Energy Tracking
- *Weekly Sleep Average calculation*: `=round(sum(this.days.sleep-duration)/7, 4)` 
- *Round the decimal*: `=round(0.<%tp.file.cursor(1)%>*60)` minutes
- **Sleep Duration**:: 
- **Sleep Comments**:: 
```dataview
table WITHOUT ID
	file.link as Date____, 
	join(list(sleep-hour, sleep-minute), ":") as "Sleep Time",
	join(list(awake-hour, awake-minute), ":") as "Awake Time", 
	sleep-duration as "Sleep Duration",
	choice(physical-activity, "✅", "❌") as "Physical Activity",
	sleep-comments as "Sleep Comments"
FROM #📓
WHERE week = this.file.link
sort file.name asc
```

##### Reflections 
###### Action Items Completed This Week, Wins, Disappointments, To Improve
```dataview
TABLE WITHOUT ID
	file.link as Date____, 
	choice(done, "✅", "❌") as "Done", do-date as "Do Date", priority, Project
FROM #✅ and !"_System" 
WHERE do-date >= date(<%tp.date.now("YYYY-MM-DD", -7)%>) 
WHERE do-date <= date(<%tp.date.now("YYYY-MM-DD")%>)
WHERE Done = 1
SORT do-date asc, priority asc, due-date asc
```
###### Habits, Priority, Focus
- Quality Habits
	- **Morning Gratitude**:: 
		- *This Week's Morning Gratitude*: `=this.days.morning-gratitude`
	- **Desired Outcome**:: 
		- *This Week's Desired Outcome*: `=this.days.desired-outcome`
	- **Morning Pages**:: 
		- *This Week's Morning Pages*: `=this.days.morning-pages` 
	- **Doing The Work**:: 
		- *This Week's Doing the Work*: `=this.days.doing-the-work` 
	- **Wins**:: 
		- *This Week's Wins *: `=this.days.wins`
	- **Disappointments**:: 
		- *This Week's Disappointments*: `=this.days.disappointments`
	- **Evening Gratitude**:: 
		- *This Week's Evening Gratitude*: `=this.days.evening-gratitude`
	- **To Improve**:: 
		- *This Week's To Improve*: `=this.days.to-improve`
- **Social**
	- Call Someone:: 
		- *This Week's Call Someone*: `=this.days.call-someone`
	- Say I Love You:: 
		- *This Week's Say I Love You*: `=this.days.say-i-love-you`
- **Top Notes**:: 
	- %%Top notes%%
		```dataview
		table  WITHOUT ID 
			dateformat(file.day, "DDDD") as "Date____", 
			top-notes as "Top Notes and Currently  Working On"
		from #📓/☀️ 
		where top-notes !=null
		WHERE week = this.file.link
		SORT file.day desc
		```

## Clean Up
- [ ] Email 
- [ ] Review Calendar 
- [ ] [[Projects]] Review 
- [ ] [[Top Notes]] Review
- [ ] Delete files from Desktop & Download Folders or other clutter 
4 Likes

Thank you!

Why don’t you use checkboxes for things like making your bed or brushing teeth? What do you put after them? An Emoji?

Tick boxes would be better, but to be honest… I don’t know how to yet! If you or someone else can suggest how, I would adopt it!

I would need an inline dataviewjs of tasks from from this.weeks, which sums the number of times the target field is marked complete.

… In the process, hopefully I’ll graduate from “making my bed” soon!

Hey, I’m right there with you. I did make my bed today although it’s been a while☺

Thanks for clarifying. It makes sense why you did it that way. I’m afraid I don’t have enough knowledge to figure out a better way.

BTW I could put anything in those fields, but I generally just put 1 in the field… And then sum the values at the end of the week.

If I start needing more info then I would change the field.

For example, I previously had a field sleep quality where I listed a value 1-10 and a sum of the results gave me an average at the weekly review note. But I changed it to sleep comments and with the weekly roll up of inline dataview it has been super effective for recognising trends in behaviours and outcomes over time - I now write something like “5/10 - had a beer at dinner, mind was racing when I tried to sleep, listened to a podcast and slept”.

Also, I’m posting my info so that learners can learn faster than I did! I’m sure you’ll be able to help me in a few weeks haha!

Finally managed to put a status bar in my digital bookshelf.

TABLE WITHOUT ID
  Title as "Books I read", Author, ("![coverimg|90](" + Cover + ")") as Cover, About, 
  (Length + " p.") as Length, ("![progress + " + (round((PagesRead/Length)*100)) + " %](https://progress-bar.dev/" +(round((PagesRead/Length)*100)) + "/)") AS Progress_____, Priority
From ""
Where Type = "Book" and Status = "Reading"
Sort Priority desc
13 Likes

Question: Is there any way to query the amount of uncompleted tasks and the amount of completed tasks in a note?

I want to make a self-updating progress bar for each project note in the ‘project overview’ table.

Last modified date with=this.file.mday stopped working with Live Preview (0.13.8)?

1 Like

That progress bar looks great but I guess it won’t work offline?

I found another solution:
<progress value="" max=""></progress>

Looks like this for my Dataview block:
("<progress value="+(round((PagesRead/TotalPages)*100))+" max=100></progress>")

This status bar works offline and is generated inside Obsidian. It is rather ugly, but I have styled it with this snippet from the user Cestvrai on the Obsidian forums. It styles the progress bar to fit your theme.

progress[value] {
/* Reset the default appearance */
-webkit-appearance: none;
appearance: none;
width: 100px;
height: 18px;
}

progress[value]::-webkit-progress-bar {
background-color: var(--background-primary-alt);
border: 1px solid var(--background-modifier-border);
border-radius: 4px;
box-shadow: inset 0px 0.5px 1px var(--background-zero);
}

progress[value]::-webkit-progress-value {
background: var(--background-modifier-accent);
box-shadow: none;
border-color: transparent;
border-radius: 4px;
}
5 Likes

Is it possible to query all YAML properties?

For each PERSON note I want to query all the notes that have that person’s “Name Surname” in the YAML front matter. However, the name may be present in many different YAML properties; As “Author”, “Co-Writer”, “Consultant”, “Receiver” etc.

How do I query all notes that contain the text “Name Surname” in their front matter?

Question -

Can I find the total number of backlinks within each page with Dataview? Each time I run my query with length(file.inlinks), I’m only seeing the number of pages referenced - not the full count of all backlinks.

In my case, we’re reviewing lengthy transcripts and coding common themes, so themes (listed as wikilinks) may come up numerous times within the same page.

I want to be able to view the entire count - as I would through the total number of backlinks.

Any advice on how I can do this with Dataview?

Thanks!

Hi!

This inline dataview does what you describe

=length(this.file.inlinks)

1 Like