Dataview plugin snippet showcase

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

is there a way to get dataview tables of tags based on headings instead of notes?

Hi all
I thought i would share the workflow i built for creating dynamic tables enabling me to change a search key & corresponding value to update a table) using Dataview in case it can be useful. I use it as my ‘google search for notes’ without creating a rigid structure of tables & sparing time going through a long list of notes.
It also enables me to remain in Preview mode and uses 3 plugins: Buttons, MetaEdit, Dataview.

YAML frontmatter:

---
QueryTerm:
QueryKey:
...
---

Dataview Query:

\```dataview
Table without id <field1>, <field2>, ....
where contains(this.QueryKey, this.QueryTerm)
sort file.name asc
\```

the trick here is that this.QueryKey will appear as a value and not as a YAML field therefore transtypage is required. In the afore-mentioned code, replace this.QueryKey with something like:
choice(contains(this.QueryKey, <value to test 1>), <corresponding YAML field1>, choice(contains(this.QueryKey, <value to test 2>), <corresponding YAML field2>, <default YAML field>))

by nesting choice statements (equivalent to ‘if statements’) as much as required.

The query will therefore look like:

\```dataview
Table without id <field1>, <field2>, ....
where contains(choice(contains(this.QueryKey, <value to test 1>), <corresponding YAML field1>, choice(contains(this.QueryKey, <value to test 2>), <corresponding YAML field2>, <default YAML field>)), this.QueryTerm)
sort file.name asc
\```

On the same note, I have a button:

\```button
name Search Library
type command
action MetaEdit: Run MetaEdit
\```

In preview mode on the note: Button ‘Search Library’ > launch MetaEdit for the note > update values of ‘QueryKey’ and/or ‘QueryTerm’ > Dataview table updates.

I hope that this can be useful!

5 Likes

Change Completed → 4_Completed, 3_To Do, 2_Paused, 1_Doing

or ABCD

SORT status ascending

Very helpful! In this example did you get lucky with the group ordering of intensity?

Green
yellow
red

I’m having trouble figuring out how to order the groupings.

So, for example, what would you do if the returned result was
Green
Red
Yellow

Is there a way to show images like this in wikilinks? This type of linking is no longer supported for images. I just can’t make it work.

Hi Jeffurry,
I did something similar to create a Date Modified in my preferred format, but when concatenating file.mtime.minute, it loses the leading zero. Do you have the same experience? Any solution?

table dateformat(file.mday, "yyyy.MM.dd")+" - "+file.mtime.hour+":"+file.mtime.minute as "Date modified"

See the third entry:
image

try this…
TABLE dateformat(file.mtime, "HH:mm") as Time FROM "" WHERE date(now) - file.mtime <= dur(1 days) SORT file.mtime desc

1 Like

Hi All,

Im trying to filter on this current week. I have the week number in the week notes as a YAML field, but I can’t figure out how to get this current week number.

TABLE
	mon,
	tue, 
	wed, 
	thu, 
	fri, 
	week, 
	year
FROM "01_Calendar_Notes" and #weekly and !#Status/Closed
Where week = THISWEEK
SORT file.name asc

Hi Rasmus,

I use Inline Dataview Fields instead of YAML because of this post here. But you may find my stuff useful.

weekly review note

Time Information
- #📓/7️⃣
- **Days**:: [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +0, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +1, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +2, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +3, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +4, tp.file.title, "YYYY-[W]ww") %>]], [[<% tp.date.now("YYYY-MM-DD", +5, tp.file.title, "YYYY-[W]ww") %>]]
	%% Create note on Sunday - days of the week include from Sunday last week to Saturday%%
- **Month**:: [[<%tp.date.now("YYYY-MM", +0, tp.file.title, "YYYY-[W]ww")%>]]  
- **Quarter**:: [[<% tp.date.now("YYYY-[Q]Q", +0, tp.file.title, "YYYY-[W]ww") %>]]
- **Year**:: [[<% tp.date.now("YYYY", +0, tp.file.title, "YYYY-[W]ww") %>]]

Example Sleep Tracker

##### Sleep and Energy Tracking
- *Weekly Sleep Average calculation*: `=round(sum(this.days.sleep-duration)/7, 4)` 
- *Round the decimal*: `=round(0.<%tp.file.cursor(1)%>*60)` minutes
- **Sleep Duration**:: 
```dataview
table WITHOUT ID
	file.link as Date____, 
	join(list(sleep-hour, sleep-minute), ":") as "Sleep Time",
	join(list(awake-hour, awake-minute), ":") as "Awake Time", 
	sleep-duration as "Sleep Duration",
	choice(physical-activity, "✅", "❌") as "Physical Activity"
FROM #📓
WHERE week = this.file.link
sort file.name asc
```

Example Habit Tracking - using inline Dataview

- **Morning Gratitude**:: 
	- *This Week's Morning Gratitude*: `=this.days.morning-gratitude`
- **Desired Outcome**:: 
	- *This Week's Desired Outcome*: `=this.days.desired-outcome`
```
1 Like