Dataview plugin snippet showcase

Cool. Thank you. That works inline, but I can’t quite manage to figure how to resolve that with my dataview query. I tried adding it into the YAML (with: links: “=length(this.file.inlinks)”), but it’s coming back as 0 across the board.

How would I go about pulling a dataview of all pages with that calculation?

1 Like

Thanks, @blacksmithgu for fixing the sorting issue. Discovered today that all of sudden the query now works as initially intended.

Question: Will dataview tables eventually slow down my vault?

I know very little of programming, so this might be a non-issue. But I am worried if having a lot of dataview tables throughout my vault will slow down my vault to eventually become unusably slow?

Dataview queries render and update when you enter the note, so keep your tables optimized!

Awesome! Thanks.

How did you get your cover to be on the side of your book information?

I wanted a table sorted by date, and I wanted the weekday in front of each date, in German (from Monday to Saturday would be: Mo Di Mi Do Fr Sa So).

What worked for me, after many trials, is to nest seven replace-functions one in another. I give an example:

Frontmatter:

searchdate: 2021-12-27
search: "winter"

Dataview Query:

table WITHOUT ID 
	replace(replace(replace(replace(replace(replace(replace(string(date.weekday), "1", "Mo"), "2", "Di"), "3", "Mi"), "4", "Do"), "5", "Fr"), "6", "Sa"), "7", "So") AS "Weekday", 
	date as "Date", 
	time AS "Time", 
	title AS "Title", 
	place AS "Place"
WHERE date(date) >= date(this.searchdate) 
	AND date(datum) <= date(this.searchdate + dur(1 years) - dur(1 days)) 
	AND contains(title, string(this.search))
SORT date, 
	time, 
	file.name
2 Likes

Hi

Do you know if there is a way to get backlinks of backlinks ?

For example, I have 201.blabla that link to 20.blabla and 202.blabla that link to 20.blabla too.

In 20.blabla, I have a table that show how many backlinks there are on 201.blabla and 202.blabla.

Now let’s imagine I have a 21.blabla.
20.blabla and 21.blabla are link to 2.blabla

In 2.blabla, I want to display 20.blabla and 21.blabla with the sum of the backlinks of their own backlink.

Someone understand ??

I have a table with this code :

```dataview
table without id file.link as Name, parent, length(file.inlinks) as "Backlinks"
from "3.Permanent Notes"
where parent = 2000
sort file.name asc

with this result :

Now I try to group by parent and have the sum of the backlinks but it doesn’t work :

Normally, it must show 8.

@Primahctuns

Just wanted to take the second to send much gratitude and I know (for me at least) writing an explanatory posts takes infinitely longer than a thank you. As well, this is exactly what helps me, and i know others, actually learn and build upon.

I’ve been messing with a query for weeks, and after as i’m sure you did, having 7 nested replace functions, sometimes after hours of “trial and error” you can’t tell if you typed it 6 or 7 times. :crazy_face:

Long winded way to say thank you and remind myself of why you just put stuff out there cause you never know who you could be helping.

@Hydro

I’m a crazy person and took my best shot at it. I think I might know what you’re saying and working on it.

However - in mean time - as a suggestion :joy::

could you actually try like writing it with:
2.1.a
2.2.b

etc.

just something besides blabla lol

(I’ve actually gone thru quite a few TBI’s and worked with soldiers, extensively studied the oddities of our brain that we don’t quite have explanations for - all that to say - all the “blablas” screw with our brain’s pattern recognition software, and when trying to understand the very thing your explaining which is a nested pattern, injecting a static pattern with no relevance convulses that)

^^^figured id provide an explanation compared to the grumpy’s on here who will literally robotically just say “Rephrase Question” - you asked if anyone followed, so i think it warranted a thorough deep dive in “question structuring”

i think @ryanjamurphy (workflow wizard, legend in the Mac Power User world) wrote up an entire detailed post on this. or @nickmilo

either way - for anybody new - just go look those two gentlemen up as they provide so much “compassionate” and nifty help all over the place.

1 Like

Thanks for your reply. Indeed my post wasn’t very clear… :sweat_smile:

In the same time and with the help of shabegom on discord, I achieve to do what I wanted to do and I even added chart for my table !

Here the results.

My level 4 MOC (2101) :

My level 3 MOC (2100) : that is parent to level 4 MOC

My level 2 MOC (2000) : that is parent to level 3 MOC

My level 1 MOC (100) : that is parent to level 2 MOC

Thanks again to shabegom.

If someone wants more informations, feel free :slight_smile:

1 Like

really nice!
Could you share the code for the graphs please? :slight_smile:

const labels = [] 
const inlinks = [] 
const data = dv.pages('"3.Permanent Notes"') 
	.where(p => p.file.name.includes("21") && !p.file.name.includes("2100"))
	.forEach(p => { 
		labels.push(p.file.name)
		inlinks.push(p.file.inlinks.length) 
	}) 
const chartData = { 
	type: 'bar', 
	data: { 
		labels: labels, 
		datasets: [{
			label: 'Backlinks', 
			data: inlinks, 
			backgroundColor: [ 'rgba(255, 99, 132, 0.2)' ], 
			borderColor: [ 'rgba(255, 99, 132, 1)' ], 
			borderWidth: 1 
		}] 
	} 
} 
window.renderChart(chartData, this.container) 
1 Like

What would be a simple query to count the number of notes with a specific #tag?

Which plugin are you using to generate a graph inside your note?

Are you able to generate a Table of Contents (TOC) using the headings within a note using dataview?

I have a large note and I want to make it easier to navigate by adding a table of the headings at the beginning.
Just found out about dataview so thank you for the help in advance.

Not what you want, but have you tried:

Settings > Core Plugins > Outline

If you then open the right sidebar, you will see a navigable outline of your note based on its headings.

You can drag and drop from the outline to the note if you want to create a TOC in the file itself.

Angel

2 Likes

Thank you! I’ll try it out and probably test out how it works/looks with the table plugin.

Hey guys, pretty new to dataviewjs, I have a query in regular dataview that displays the age of a note but recently I replaced it with a dataviewjs query with more functionality. The problem is, I do not know how to pull in the same Age output in the dataviewjs query:

TABLE WITHOUT ID status as "status__", file.link as "Name", date(today) - file.day as "Age_____"
FROM #🌱/📝 AND !"Templates" and -"periodic"
SORT (date(today) - file.day) DESC

For my note processing dashboard, I’d like to know the age of the note. Here is my new query:

const {update} = this.app.plugins.plugins["metaedit"].api
const {createButton} = app.plugins.plugins["buttons"]
dv.paragraph("### 📝 New Index/ Miscellaneous Notes");
dv.table(["Name", "", ""], dv.pages("#🌱/📝" + ' and !"templates"')
    .sort(t => t.file.mtime, 'asc')
    .where(t => t.status == "#🌱/📝")
    .map(t => [t.file.link,
    createButton({app, el: this.container, args: {name: "🌱"}, clickOverride: {click: update, params: ['status', '#🌱/📝', t.file.path]}}),
    createButton({app, el: this.container, args: {name: "🌞"}, clickOverride: {click: update, params: ['status', '#🌞/📝', t.file.path]}}),
    createButton({app, el: this.container, args: {name: "🌲"}, clickOverride: {click: update, params: ['status', '#🌲/📝', t.file.path]}})
]
)
    )

If anyone could help out, I’d be incredibly grateful! I really enjoy seeing how to recreate simple dataview queries in dataviewjs and would be interested in learning javascript just for this reason!

1 Like