Dataview plugin snippet showcase

Weird - it is returning 0 results. I set the folder (Journal/) wherein each year has a folder - but nothing. I changed it to this…

```dataview
list from ""
where contains(file.name, "03-10")
```

and got the list. Could you explain the bits in curly brackets. Very sorry, as I realise this is a painfully newbie request!

Is it working the way you want after the change? :slightly_smiling_face:

Ahh sorry, I assumed you were using the Templater plugin! The part in brackets fetches the current date {{tp_date}}2021-03-10 when you run the template.

{{tp_date:f=MM-DD}} returns the current month MM and day DD03-10.

f= means “use this date format:”

1 Like

Ah! Putting it in my Daily Note template (yes , Templater) did the trick. I now get the list.
Ideally I would like each entry in the list to render in an ![[embedded preview]]. Is that feasible?

Nice! :grinning_face_with_smiling_eyes:

At the moment, no. I don’t think you can create a list of embedded links.
I’m unsure if this would require writing to the file (which dataview doesn’t do).

OK - thanks for your help :grinning: :+1:

1 Like

I’ve been using it to create a more manageable list of what articles I’m planning to write for which markets in order of how “far along” they are and what their status is (pitched, drafted, published, etc).

dataview
table file.size, market 
from "90 Articles"
where current-status = "seed"
sort file.size desc

I also combine it with the calendar plugin to list files created on a particular date:

dataview
list file.ctime 
where file.ctime > this.file.day and file.ctime < (this.file.day + dur(1 day))
sort file.ctime asc

You can change ctime to mtime to get files last modified on a particular date but I find that to generally be less useful for me personally.

I also like to use dataview to help organize some of my fiction.

dataview
table year, length, status, protagonist, location, pitch
from ""
where universe = "Verraine" AND status != "deleted"
sort year asc

coupled with YAML at the top of my novel index notes and my short fiction along these lines:

---
universe: Verraine
year: 450
status: begun
protagonist: Jack
location: Efrenzan
length: short story
pitch: "A young soldier arrives home on leave to find the village he left behind devastated — and the girl who once spurned him, his only hope." 
---

lets me create a very useful chronological list of stories that take place in a particular universe (I have three that I write in regularly, depending on genre: science fiction, urban fantasy, and second world epic fantasy).

For example:

Note that Irella is a link. I’m holding off refactoring everything to match that style because I’m hoping we’ll be able to assign “link” status on the dataview side instead of in the YAML and it’s not a huge deal right now, but you can do it by giving [[destination]] in the raw YAML. Obsidian won’t recognize it, but dataview does.

For individual novels, it also lets me create an incredibly helpful outline, like so:

dataview
table chapter, location, time, pitch
from ""
where (story = "Civil Mage") AND (chapter != "00") AND (status != "deleted")
sort chapter asc

where the YAML style would be:

---
story: "Civil Mage"
protagonist: "Irella"
length: "chapter"
chapter: "02"
section: 2 - Call to Adventure 
status: "complete"
location: Oruku
time: day 0 (midsummer) 
pitch: Irella attempts to gain support from the new Soveriegn, Valentia, but is rebuffed as a political liability and shuffled off to the minor, ceremonial role of tomb-builder.  
---
14 Likes

For those who may not know, you can use emoji in frontmatter, which works just fine in dataview!

I use coloured squares to indicate the amount of work required for each of my assessments.

image

19 Likes

I’m test-driving a version of this thanks to you @EleanorKonik and enjoying it so far.

Ooo, good call on the emojis @SkepticMystic . That will make many people very happy!

2 Likes

I love this idea!!

1 Like

If / when you get it set up to make a nice fancy “inbox” for MOCs, report back, because I am very interested !

1 Like

Has anyone noticed the exclusion filter stopped worked recently, or is it just me?
I use Dataview as a way to generate my MOCs. My code hasn’t changed in a while, but for some reason it has recently started to include in the results the files that are supposed to be excluded.

TABLE from #mental-models or #principles or #problem-solving 
WHERE file.name != "000 Index.md" AND file.name != "020 Mental Models MOC.md"
SORT file.name asc

This very simple file name exclusion works here (Obsidian 0.11.5, Dataview 0.1.10 on Linux/AppImage):

table file.ctime, file.mtime
from "+Inbox"
where file.name != "+Inbox TOC"
sort file.mtime descending

Maybe you need to leave out the “.md”? file.name seems to work on the file title, actually.

3 Likes

Well, that is all it took. Thank you very much, it’s working :slight_smile:

1 Like

How would one go about saying:
list from #dessert but not #icecream?

I’ve tried a few things (from #dessert and !=#icecream) (with or without space between = and icecream but it doesn’t work. I’ve also tried without the and.

I tried to exclude via the where clause, but there’s no way I can see to exclude tags there; just path and name.

Hi @SkepticMystic. Awesome. Would you be able to share the code behind this?

1 Like

I also just tried a bunch of tests, but I don’t think this is possible.

#foo and not #bar
#foo not #bar
#foo and !#bar
#foo !#bar

I think this is a useful and easy-to-implement suggestion. Perhaps post an issue on the GitHub page :slight_smile:

2 Likes

It’s just a normal Table, only difference is that each of the notes’ metadata has an intensity: :green_square: field.

(Without the backticks → “intensity: :green_square:”)

image

So the codeblock:

Table intensity
From #Assignments

Will give you the emoji :slight_smile:

image

I use the Emoji Toolbar plugin to more easily insert emoji

3 Likes

@SkepticMystic

I think this is a useful and easy-to-implement suggestion. Perhaps post an issue on the GitHub page

done

1 Like

Nice :slight_smile:

Regarding your second point in the gh issue, doesn’t this work? Where !contains(file.name, "Ice Cream")?

I use this to exclude templates from the results:

image

Hi @SkepticMystic. I also use Emoji Toolbar plugin. Super thanx for sharring. I was not aware of the full potential of Yaml. I did watch a few YT video’s and if you combine Yaml with Dataview you can build great things. And in combination with the Templater plugin it becomes AWESOME.
I put this in a Template for each note when I create them
image
Then I use this Dataview to create the Dashboard

TABLE bnr, status, type, who
FROM "" and #BNR12583  
WHERE date(now) - file.mtime <= dur(365 days) 
SORT file.mtime desc

And this is the result

8 Likes