Dataview plugin snippet showcase

This is so insanely usefull that I can’t even express how cool and usefull I find it. Thank you!

2 Likes

I would add also this:

WHERE file.name != this.file.name

And this:

Projects due today or within a week from today

TABLE tags, deadline
FROM ""
WHERE deadline - date({{date:YYYY-MM-DD}}T23:59) <= dur(7 days)
SORT deadline ASC
1 Like

I have YAML in the form of this


date:
array:

  • detail1: “A”
  • detail2: “B1”
  • detail1: “A”
  • detail2: “B2”

I am trying to have a table set up with the columns date, detail1, detail2 but I am not making any progress

The closest I can get is this query

table array.detail1, array.detail2

But there are annoying space consuming bullet points on my preview. I want a flat inventory like spreadsheet to be rendered

Like this?

A CSS snippet can suppress the bullets:

/* dataview lists */ 

.dataview-result-list-root-ul 
{
    padding: 0em !important;
    margin: 0em !important;
    list-style-type: none !important;
}

Angel

Can you please give full the dataview query? I have never used css before, I tried copy pasting that code in various intuitive places and couldn’t get desired results

Apologies. Only just seen your message.

The full dataview query is in the post above, localised to query files in my vault’s inbox.

The CSS isn’t part of the query; it is part of the styling used in the preview pane / output.

See the help directory for adding CSS snippets:

Angel

EDIT: the post below has a small sample CSS snippet and details about how to enable it. You could, perhaps, use it to see how CSS in Obsidian works. It is non-destructive and easily removed.

1 Like

Hi Angel I got up to speed with css snippets today and implemented your example. The issue for me is that the bullet points aren’t the problem as much as the space they take up. Is it possible for the example table to only have two rows rather than the four they currently occupy?

UPDATE: My bad, I borked. I missed the fact that YAML demands the metadata section to be at the very top. However, I have two problems with dataview.

The minor one is that the following doesn’t work for me:

TASK
FROM "tasks"
WHERE (due = date(today)) AND !completed

As you might have guessed, I’m trying to show all non-completed tasks for Today. It returns zero results.

However, my major problem, that I’ve also mentioned below, is that dataview doesn’t work for me at-all on Android. Is it compatible only with the desktop version of Obsidian? If not, any ideas how to troubleshoot/fix the problem?

Feel free to ignore everything below. I’m leaving it here for anyone who wants to laugh at my absent-mindedness.


For some reason I’m not able to make the boolean logic work with dataview in my setup. I’d appreciate some help, since I’ve already spent hours trying to solve the problem and failing.

I’m trying a task management setup where I’ll keep all task-related notes in a folder (named “tasks”, in Obsidian Vault’s root). Then, I want to “pull” all tasks from there and have them listed in a single note, named “010_Tasks”. My goal is to have this page, with all my tasks, easily accessible on both my PC and Android smartphone.

Each note with tasks might contain one or multiple tasks. Its structure goes like this:

# Title Like X-Project Tasks
%%
- - -
**Link:** [[Main_Project_Page]]
**Tags:** #maintag/subtag
**Time:** 15:30 Friday, 01-10-21
**Date:** 2021-10-02

**Notes:** 
Anything goes here...
- - -
%%

- [ ] Task 1
- [ ] Task 2
- [ ] Maybe a 3rd one, too!

My first problem’s on the PC. I’m trying to create some dataview rules that will pull data from all files in the same folder (“tasks”), but only present the tasks that match a particular tag. My latest failed attempt is this:

TASK
FROM "tasks"
WHERE Tags = "#maintag/subtag"

…and, ideally, there should also be a “!completed” somewhere, to hide completed tasks. I haven’t even reached that point yet. The output from the above shows nothing. I’ve tried enclosing the Tags = “#maintag/subtag” in parentheses. Nothing. What gives?

Also, on mobile it’s even worse: dataview seems to not be working at all. A plain…

TASK FROM "tasks" WHERE !completed

…that does work on my desktop PC shows nothing on my smartphone.

So… Any ideas on what I’m doing wrong? I’m floored by what you’ve all achieved, and I can’t even proceed to the first step!

Hi all,

I am new to Obsidian and dataview.
I am currently investigating using dataviewjs to extract the notes contains a certain string in a field.
For example, I have to extract all the notes with Name contains string “John”.
It might be Name :: John 123/ Name :: John abc/ Name :: Johnny

I am currently using

dv.list(dv.pages("").where(k => k.name.includes("John")))

But it prompted me the error:
Evaluation Error: TypeError: Cannot read property ‘includes’ of undefined at eval

May I have your help on this?
Thank You so much

how can i get backlins to notes in a dataview table?

@Archie

dataview 
LIST
WHERE
	contains(this.file.inlinks, file.link)
	AND 
	!contains(this.file.outlinks, file.link) 
4 Likes

thanks. it is interesting but i am asking for something else. i want the results in the table show their backlinks in the table, i think i should use table file.inlinks as links to get that. what is the difference between inlinks and outlinks?

Hello everyone,
Any way to create a dataview query which will show all backlinks to a heading?? Currently this will show all links from the entire note and not just the heading. I am not sure if I am doing something wrong or if it is just not supposed to work like that.

Tank you!

this.file.inlinks are all the files with incoming links
this.file.outlinks are all the links mentioned in this current file going out - so you could delete this one. But I prefer to have this excluded (!) in my dataview list, because that means only the backlink files that “I don’t know about already” show up.

dataview 
TABLE file.mday as "date modified"
WHERE
	contains(this.file.inlinks, file.link)
2 Likes

Hey,

I’m trying to create a table of schedule in my weekly note from items scheduled on my daily notes.

My daily notes are titled yyyyMMdd-ddd. In my daily notes I have the format:
[cal:: appt description] [schedule:: yyyy-MM-ddTHHmm]

In my weekly notes I have the field monday-date::yyyy-MM-dd. In these, I’m trying to roll up the daily calendar fields so that I get a table with
| file/date | HH:mm | calendar item |

I’ve tried:

table dateformat(schedule,"HH:mm") as "Time", cal as "Item"
from "notes/2021"
where note-type="daily" 
and dateformat(schedule,"yyyy-MM-dd") >= dateformat(this.monday-date,"yyyy-MM-dd") and dateformat(schedule,"yyyy-MM-dd") <= dateformat(this.monday-date,"yyyy-MM-dd") + dur(7 days)
sort file.day desc 

This returns zero results.

A couple of notes:

  • changing the first > to < in the second where query (so that it reads dateformat(schedule,"yyyy-MM-dd") <= this.monday-date shows the schedule from Monday… not sure why >= and <= the same day would not both show that day
  • file.day.week= the 1,2, etc week of that month (e.g. returns 1 for the first week of october, instead of the universal week of the year)
  • file.date.week/month/etc does not return anything
  • I don’t always create the file during the week, sometimes I create it before so file.ctime is not an option
  • If I remove the 3rd where clause so that the where query reads where note-type="daily" and dateformat(schedule,"yyyy-MM-dd") >= this.monday-date I get returns from the prior Saturday (very weird) and the following Wednesday only, even though I have tasks Monday, Tues, Wed & Thurs
  • dateformat(file.monday-date, "yyyy-MM-dd") + dur(1 day) does not return the following day as expected, and instead produces 2021-10-04null` which probably means it’s not really/always being treated as a date? but I don’t know enough to read through the lines and learn from this.
  • and small aside, when adding the date to the schedule field, e.g. schedule:: 2021-10-05T06:18:00, the dateformat command reads the first value after the T as the hour instead of as the timezone, so I’ve adjusted the formatting for my scheduling (this may be a bug? I’m not sure)

Thanks for any help!

Pulling various numbers from inline fields and cannot get the numbers to format correctly.

Numbers such as 9999.99 display correctly but 9999.90 displays as 9999.9 in my dataview query. Is there a way to format numbers so the trailing 0 shows and numbers align to the right? (If it is 9999.00 it drops both trailing .00)

Now Aligns left
1234.55
1234.5
11234.55
11234

What I would Like to see Align Right so numbers line up
1234.55
1234.50
11234.55
11234.00

I have searched the forums and plugin website but cannot find a way to do this? Anna help appreciated, THX

Thanks for this. Is there a way I can use the query with a dynamic variable, say file name of the note

As I mention here Using Local Images as Cover - #6 by FranEgea

I need to link local files in the vault not in the disk. The problem is that in my phone with sync Obsidian, it cant find the file because obviously is not in disc “C” or “D”. And I dont want to upload my files in imgur or something like that. Does anyone know how?


Hello,

Do you know if there is a way to count the occurrences of a specific tag (#test) in a list of files contained in a folder and generate an output like this?

Document           | Occurrences of #test
-------------------+--------------------
file1              | 54
file2              | 12
file3              | 0
file4              | 3
file5              | 21

Thanks!

2 Likes

Hi guys, does anyone know how to do dataview sorting explicitly. That is to say:

I have notes with YAML field “status”. Some of them have values ​​like: To Do, Doing, Paused, Completed.

How could I do a manual ordering of the elements of the table and not by alphabet?

SORT status ["Doing", "Paused, To Do, Completed"]

PS: This is not how it is done, I just put an example of what I want to express.

I would like to get this:

Note status
Eat Doing
Fun Paused
Run 5Km To Do
Learn Completed