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.:
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…
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.
You use this yaml example:
… 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").
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:
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?