Dataview plugin snippet showcase

hi guys, kinda off topic but…

I came back to using yaml and using obsidian as a project manager. but I lost so much time to error’s in parsing yaml. mostly because of tabs inserted when I use Enter (using outliner plugin). I wish there was a plugin or something to let me know when there is an error in any yaml. anyone had the same problem or it’s just me being new to this topic

You could try the MetaEdit plugin. It helps adding/editing both YAML and inline Dataview fields. So you can always ensure both correct spellings and formatting. You can also set a list of predefined values for certain fields which is amazing.

1 Like

Any reliable way to filter by checking if an array includes a value? I have files with:

---
School: [NFHS]
---

and

---
School: [NFHS, FHS]
---

When I use the following, both files are returned:

```dataview
TABLE Season
WHERE contains(School,"FHS")

Any way to create a query that would only return the second file?
Thanks!

Thanks. It is looks like just what I need, but the documentation on it is so short and confusing. How I can edit yaml values from dataview tables? and what are those “::” . how i can use these predefined values I set in the plugin’s setting?

p.s. I get how predefined value works now. but how i am going to set it for nested values? for example I am going to set some predefined values for project.info.status? not just simple status?

is there a way to make these update like in the main not? they don’t get updated and recognized for backlinks as far as i can see

YAML in Obsidian needs to always be at the top of the note. Dataview allows using other YAML like fields and the :: is their syntax. These Dataview inline fields function just like YAML but can be used anywhere in the body of the note.

I’m not too familiar with the specifics of the MetaEdit plugin. I’d suggest posting in their Github or starting a new thread, since this post is specific to Dataview and also is meant to be a showcase rather than a help post.

1 Like

DataView returns both files because “NFHS” also contains the term “FHS”. Did u try if it works with a blank?

WHERE contains(School," FHS")

Thanks for the suggestion, but that does not work. Even it did work, I also have files with simply

---
School: [FHS]
---

that also would need to be returned. Thanks again!

Since 0.4.0, econtains or “exact contains” allows you to look for exact matches only rather than substrings. There isn’t documentation on it quite yet but the following should hopefully work

```dataview
TABLE Season
WHERE econtains(School, "FHS")
```
1 Like

Thanks @M_bot, that worked great!

It ultimately isn’t a problem for my purposes, but I did note that I had a file that had a school not in an array (School: NFHS) that was still being matched with econtains. Once I put it inside brackets it worked as expected.

You can change the default date format and the default datetime format in the plugin settings, very last settings.

Also, from version 0.4.3 released a few days ago, we can use dateformat and format - So for example, to represent just the week of a date (format “W”) we can do something like dateformat(date(file.name), “W”) - relevant discussion: Is it possible to specify a format when displaying a date? · Discussion #362 · blacksmithgu/obsidian-dataview · GitHub

2 Likes

You could use an even shorter version (provided your file name contains a date):

Week: `=dateformat(this.file.day, "W")`

I opened ticket that internal images are not shown:

This is brilliant Ross, thanks so much!
Quick q: is there a way to exclude from this list backlinks that I’ve already linked to in the file?
@SkepticMystic

Any way… How I can exclude the current file from search query?

where file.name != this.file.name

3 Likes

Gold! This plugin is just gold! Thank you @Moonbase59

1 Like

I did. It’s just a simple css class:

span.nav {
  border-top: 1px solid var(--gray-dark-3);
  border-bottom: 1px solid var(--gray-dark-3);
  clear: right;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
1 Like

Anyone else able to help me with this?
How can I list backlinks and exclude notes I’ve already linked to?
paging @Moonbase59

List of backlinks not including outgoing links from this note

I made a short description, so that everyone can follow how to do things like that. It requires ```dataviewjs though.

Here’s what it looks like

Here’s the code

# List of backlinks not including outgoing links from this note

An outlink: [[Test Dataview Links]]

### outlinks

```dataview
list from outgoing([[#]])
```

### inlinks

```dataview
list from [[#]]
```

### Backlinks w/o the outgoing links

You can simply filter one array's elements by setting the condition based on other array's elements.

The `some()` method tests whether at least one element in the array passes the test implemented by the provided function. And I’ve added a function which just checks if the inlink path exists in the outlinks array with the same value to be able to filter from the first array using a `not` (`!`).

#### Long form for better understanding

```dataviewjs
var outlinks = dv.current().file.outlinks;
var inlinks = dv.current().file.inlinks;

dv.list(inlinks.filter(i => !outlinks.some(o => o.path === i.path)));
```

#### Short form

```dataviewjs
dv.list(dv.current().file.inlinks
    .filter(i => !dv.current().file.outlinks.some(
        o => o.path === i.path)));
```
10 Likes