Dataview plugin snippet showcase

Hi @PorcoRosso I like this a lot. You can simplify your statement by doing the following:

LIST
join(choice(file.tasks.completed, "●", "○"), "")
FROM #current_project

No need for Javacript, and it’s a little bit easier to read I think.

join function

choice function

12 Likes

Cool @dugdun , that’s very elegant. Will use that instead :slight_smile: .

1 Like

Hello! thank you both for this idea and showcase, it’s a very interesting concept and very intuitive to implement.

I was wondering, is there a way to increase the resultant size of “●”, “○” that @dugdun is using in his dataview?

Hi @stfrigerioj remember that the dots are just regular characters being displayed. If you want, you can use inline styles to change the size of those. Something like the following would make them 1.5 times bigger than they normally would:

LIST
join(choice(
	file.tasks.completed,
	"<span style='font-size:150%;'>●</span>",
	"<span style='font-size:150%;'>○</span>"
), "")
FROM #projecta

You can use any type of CSS styling that you would like.

7 Likes

Wow this is awesome! As a newbie with css, these insight are priceless. Thank you so much for your help

1 Like

Part showcase, part question: I am trying to create something like the Tag pane core plugin but inline and filtered for creating a dynamic MOC index of tags meeting a regex criteria.

Here is a tag index dataview code that I found here (thanks @mnvwvnm !) that I sparsely modified to list in alphabetical order.

TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")") 
AS Tags, join(rows.file.link, ", ") AS Files FROM "" 
WHERE file.tags 
FLATTEN file.tags AS tag 
GROUP BY tag 
SORT rows.tag ASC 

Q: How do I modify this to filter by the #tool tag and subtags? (Using WHERE contains(file.tag, “tool”) or similar doesn’t work because it also grabs all of the other tags referenced in that file.

4 Likes

If I understand correctly… try this:

```dataview
TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")") AS Tags, join(rows.file.link, ", ") AS Files
WHERE file.tags 
FLATTEN file.tags AS tag
WHERE contains(tag, "tool")
GROUP BY tag 
SORT rows.tag ASC
```
7 Likes

Perfect!

Here is the result - I like how it returns both “tool/*” and “tools” - exactly what I wanted.

5 Likes

Hey Dug, another elegant solution!

Is it possible to tweak this further to filter out notes without any assigned task?

paoloap, if you want to only show notes that have tasks associated with them, then you can add a WHERE clause to the query:

```dataview
TABLE
		join(choice(file.tasks.completed, "●", "○"), "") as status
FROM
		#current_project
WHERE
		file.tasks
```

This will only return notes that have tasks in them.

Should you need to find notes that don’t have tasks in the future, you can negate the WHERE clause as follows:

WHERE
    !file.tasks

The ! character means not, so you’re looking for note where there is not any tasks.

3 Likes

This is something I recently discovered, but an empty [[]] queries for pages linked to the current note:

list from [[]]
sort file.name asc
6 Likes

Aggregating all of my tasks into one note, sorted in a descending manner.

'''dataviewjs
dv.taskList(dv.pages().file.tasks
.where(t => !t.completed).sort(t => t.path, 'desc'))
'''
4 Likes

Absoloutly perfect!

1 Like

So I’ve just started using Dataview and discovered it has a Calendar display, and I’d like to use it to fetch a metadata field from daily notes and add it to that day in the calendar. I can do it, but what I can’t do is style the dots that appear in the calendar.

I want to have an “activities” field for each day which can have one or more activities, and then have a color coded dot or a symbol in the calendar for that day. Sort of what this plugin does GitHub - duoani/obsidian-habit-tracker: This plguin for Obsidian creates a simple month view for visualizing your punch records. but pulling it from within each daily note.

Is there any way to do this?

Quick update on my task aggregator, which is updated to ignore a specific page (ignore tasks in my Media note):

'''dataviewjs
dv.taskList(dv.pages().file
  .where(f => f.name != "Media")
  .tasks
  .where(t => !t.completed)
  .sort(t => t.path, 'desc'))
'''
4 Likes

How do I always round down with Dataview? I’m calculating age with an inline field. Floor does not work.

= round((date(today) - this.Dob).years)

Try the following to see it it works for you:

`= round((date(today) - this.Dob).years - 0.5)`

This should be similar to how floor() works. You could add 0.5 to replicate ceil().

4 Likes

Works great, I was overthinking it, thanks!

Looking at this, it should be possible to search for parts of link titles. I have files named “1st Karlovy Vary IFF”, “2nd Karlovy Vary IFF”, etc. I want to list all notes linking to any of these by searching for “Karlovy Vary IFF” in a link. But this doesn’t work:

LIST
WHERE contains(file.outlinks, "Karlovy Vary IFF")

Why doesn’t this work? Can I only do this with dataviewjs?
Thanks!

@erazlogo, I was happy to explore this for you. You have already looked for the out links of the file, but now you need to say “only if its file name contains this text…”

file.outlinks.file.name

2 Likes