Dataview plugin snippet showcase

Very helpful! In this example did you get lucky with the group ordering of intensity?

Green
yellow
red

I’m having trouble figuring out how to order the groupings.

So, for example, what would you do if the returned result was
Green
Red
Yellow

Is there a way to show images like this in wikilinks? This type of linking is no longer supported for images. I just can’t make it work.

Hi Jeffurry,
I did something similar to create a Date Modified in my preferred format, but when concatenating file.mtime.minute, it loses the leading zero. Do you have the same experience? Any solution?

table dateformat(file.mday, "yyyy.MM.dd")+" - "+file.mtime.hour+":"+file.mtime.minute as "Date modified"

See the third entry:
image

try this…
TABLE dateformat(file.mtime, "HH:mm") as Time FROM "" WHERE date(now) - file.mtime <= dur(1 days) SORT file.mtime desc

1 Like

Hi All,

Im trying to filter on this current week. I have the week number in the week notes as a YAML field, but I can’t figure out how to get this current week number.

TABLE
	mon,
	tue, 
	wed, 
	thu, 
	fri, 
	week, 
	year
FROM "01_Calendar_Notes" and #weekly and !#Status/Closed
Where week = THISWEEK
SORT file.name asc

Hi Rasmus,

I use Inline Dataview Fields instead of YAML because of this post here. But you may find my stuff useful.

weekly review note

Time 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") %>]]

Example Sleep Tracker

##### 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**:: 
```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"
FROM #📓
WHERE week = this.file.link
sort file.name asc
```

Example Habit Tracking - using inline Dataview

- **Morning Gratitude**:: 
	- *This Week's Morning Gratitude*: `=this.days.morning-gratitude`
- **Desired Outcome**:: 
	- *This Week's Desired Outcome*: `=this.days.desired-outcome`
```
1 Like

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