Dataview Problems with "nul" Metadata

I have been learning to use the Dataview plugin to make lists and tables of my notes using custom fields. So far I found that while on the surface, the plugin works great, the plugin does NOT give me all the notes for a certain criteria. The problem seems to be related to having “null” values assigned to a field.

I was using templates to bring in metadata, into many different kinds of notes, leaving some of the values blank. i.e.:


aliases:
tags:
type: review
type: book
ISBN:
author:

so there are many notes now in my vault with some null values in various fields. Obsidian seems to say that this is valid YAML code, as the notes look fine in read mode.

doing a dataview query, "where type = “book”, dv will pick up some of the relevant notes, but not all of them. Of course this is just one example.

I checked the Development Console and found there were all kinds of errors from Metadata where the value was set to ‘null.’ I suspect that it is the blanks that I left in the metadata all over my vault that is causing the errors and causing the Dataview plugin to not to work 100% of the time.

Have you seen this before?

How do you folks deal with wanting to use a template for Metadata, to keep the formats the same, and not setting “null” values for items in the Metadata?

Maybe the answer is to have all the values you might like in the template, but once you use the template in a file, erase all to items that are not used immediately…

What I’m trying to do

Hi.
Maybe you need to place here some concrete examples to debug the issue.

Ignoring the “null” thing, the only example you give us have a basic error in your side in the way you work with the fields.
Explaining…
You use this yaml example:

---
aliases:
tags:
type: review
type: book
ISBN:
author:
---

… and claim about the lack of accuracy with the query (you don’t give us the full query) with the filter

WHERE type = "book"

Well, you have TWO FIELDS in your frontmatter with the key name type! This is a wrong way to place multiple values in frontmatter fields! Do you know that in your example only the second type is parsed as a real pair key: value (type: book) and the first type: review is ignored? In this case if your write a query with the filter WHERE type = "review" this example note is ignored and not listed in the results!

So, before any pseudo-issue with the “null” metadata you need to check the way you write the metadata and the best way to write multiple values (and if valid multiple values you can’t use WHERE type = "book" but WHERE contains(type, "book").

1 Like

Thanks so much. You pinned this one down! Since yesterday’s post, I discovered that if I used the line "where contains(type, “book”) I would get all the relevant notes. This find certainly is in line with your explanation. So maybe the duplication of field names is what I need to change to get rid of all the errors I am seeing in the Development Console. I had used type = [this,that,them] as well as type = [this, that, them] and did not see a difference in how dv gets them. This format is a bit easier to write than:
type =

  • this
  • that
  • them
    and to be sure that the YAML format is correct. And I thought that simply repeating the “type” was equivalent.

Thanks for the clarification.

without getting far off this topic, are there tutorials or help to use the Development Console and trace the errors back to the note/s causing it?

best regards

Hello,

I have an other issue which i have not been able to debug,hope you can help me with this one:

In each of my notes i have a metadata which name is MOC (for map of content)

And when I put a querry such as
‘’’ dataview
Table MOC

‘’’

It returns a table with the list of notes i have but there’s nothing in the field MOC only “-”. I dont’ understand why…

Example of one of my note

Note jamesbond movie tomorrow never die


MOC: [[CINEMA]]
Tag:


blablabla

Thanks

  1. If MOC: field is placed in yaml frontmatter, then for links you need to quote them:
---
MOC: "[[CINEMA]]"
---
  1. If you want to see in the table only the files where you have the MOC field:
```dataview
TABLE MOC
WHERE MOC
```

Thanks for your answer, I tried, apparently not working.
In an other post someone said: that is due to a space to add after a column. I don’t get this explanation… I must be missing something about dataview - #3 by mnvwvnm

I add some more information


My query:

‘’’ dataview
Table MOC

‘’’

Results i Have and exemple of a note: see the images

The problem is: if you want to work with yaml frontmatter (and not with the dataview specific inline fields), you need to do properly an yaml frontmatter.

You don’t have an yaml frontmatter:

Front matter is a section of plain text attributes that starts at the first line of the file.

Thanks i get it now