Dataview plugin snippet showcase

Apologies if this has been asked a million times.

Is it possible for the following to return the text block, instead of returning a list of pages?

list from #Task

It may not align with the way you’ve structured your tasks, but you can use Task from #Task to return all checkboxes - [ ] .
Otherwise, dataview doesn’t currently allow you to embed the content of a note

It’s probably simple but I could not manage it:
Outgoing links from all notes with a specific #tag

Any ideas?

Does this work:

list from outgoing([[Note]]) and #tag

But there are many notes with that specific tag. So I cannot mention one specific [[Note]]. I think I was not clear…

let me try again: #emotion is a tag that is included in multiple notes. These notes have outgoing links. I am trying to make a table that lists the note names tagged with #emotion in one column and list the outgoing links (from each note tagged #emotion) in a second column. :man_shrugging:

Hi all. I’m trying to create a way to list notes whose date field is greater than a duration, where the duration is another field value.

My YAML looks like this:

project:
    name: "my project"
    review_schedule: 1 week
    last_reviewed: 2021-04-01

With my desired query looking something like this


```dataview
TABLE project.name WHERE date(today) - project.last_reviewed >= dur( project.review_schedule )

It works if I harcode dur( 1 week ) but doesn’t seem to convert project.review_schedule to the equivalent.

Any suggestions?

What is the syntax to search for a specific word inside a file from the entire vault?
This one is not working

```dataview
list "foo bar"
from ""
sort file.name asc

Ahh I see. That would require a general file.links property which is not currently accessible.
This is the same as the difference between asking for all notes with the tag #Tag, and fetching the tags from all notes with the tag #Tag. With this example, we can do both because we have the file.tags property. But file.links is not available

3 Likes

You can’t query the content of a file at the moment. Something like file.content would be amazingly powerful, though!

Interesting question! I played around with it, and it seems that if you have a yaml field with a number and a time duration - just like you have there 1 week - then you don’t have to tell dataview that it is a duration!
So your query should work like this:

TABLE project.name 
WHERE date(today) - project.last_reviewed >= project.review_schedule
2 Likes

I’ll try this one :v: if it works it will require to insert that new yaml element to all notes. IS that right?

Just to be sure, file.links is not a real property dataview can access. I use it as a hypothetical example.
But, like you say, if you added the links in the yaml frontmatter, you could get it to work in that way

Hey everyone - gradually getting up to speed with Obsidian and generally very excited about the possibilities that Dataview can bring.

I’m having some issues though with what I think should be a fairly basic use case. Basically I’m trying to avoid putting tags in the body of my content and placing them in the YAML instead.

Here’s what I’ve got so far (for book notes)

YAML:

---
source: Ego Is the Enemy
author: Ryan Holiday
tags: [highlights]
---

Dataview:

```dataview
table source, author
where contains(file.tags, "highlights")
```

Unfortunately though, Dataview isn’t finding anything. Can anyone point out what I’m doing wrong?

And as a secondary question, how I would need to amend my contains() function to match more than one tag?

Thanks hugely in advance!

I think you’re missing a from. Does the following work?

table source, author
from #highlights

Maybe it’s just me but I’ve found that using LIMIT for a query that sorts by date (asc/desc) won’t work. The query works/sort fine without it.

Another question: Is there a syntax to shorten the file.ctime output (ie: to just DD-MM)? I guess there is no default attribute such as file.date?

A few ways you could do this, last one is what I think you’re looking for.

  1. Extract the properties you care about from file.ctime using .day and .month into two different columns

So this:

table file.ctime.day, file.ctime.month

Will give you this:

  1. Make a list of those two properties to have them in one column:

So this:

table list(file.ctime.day,file.ctime.month) as creation

Will give you this:

image

  1. Use string concatenation to combine the relevant properties into one cell:

So this:

table file.ctime.day + "-" + file.ctime.month as creation

Will give you this:

image

4 Likes

What an awesome plugin. Thanks for developing it.

I would like to achieve something really simple to print only mtime under the title of a note.

I tried

list file.mtime

But then I got a list of all notes and their mtime. It also shows the title of the note which is not necessary.

Is this is possible?

Hey Jan! I didn’t develop dataview, I’m just a big fan :grinning_face_with_smiling_eyes:

You can use this hacky way of doing it:

table rows.file.mtime as Modified
where file.name = this.file.name
group by file.name

Will give you this table:

4 Likes

:smile: thanks for this.
It’s a bit much for what I want (space wise) so I continue my quest to find a way to add mtime as a single text string. If you run into something like that somewhere in the future please let me know!

2 Likes