YAML metadata error in Dataview with `link()`

Hello everyone.

I’m using Dataview to show these attributes that is in the YAML, and show as a link, but in some metadata It’s not working

YAML:

target_completion:
 week: 2023-W10
 month: 2023-03
 quarter: 2023-Q1
 year: 2023

Dataview:

=link(this.target_completion.week)
=link(this.target_completion.month)
=link(this.target_completion.quarter)
=link(this.target_completion.year)

ERROR:

It’s related to implicit types of your metadata. Those working are strings, which is what the link() expect to see. The second is an actual date, and the last one is just a number. See Literals - Dataview, as to what is recognised as dates.

Adding quotes

To ensure that they’re strings you need to add quotes, but even that is troublesome with the month variant, so one way would be to add a space, but then again that’ll change the value of it as well.

target_completion:
 week: "2023-W10"
 month: "2023-03 "
 quarter: "2023-Q1"
 year: "2023"

Notice the extra space on the month variant.

Using string()

Do also notice that if you use the string() it tries to be smart and present the variables in a variant you might like, which fails for the month variant:

So to actually show these as links, you need to do the following:

Show as links - "[[ ... ]]"

To get them to show as links within a query, like below:

You need to do this:

target_completion:
 week: "[[2023-W10]]"
 month: "[[2023-03]]"
 quarter: "[[2023-Q1]]"
 year: "[[2023]]"

Which has another caveat, that it’s not easily comparable to other dates, so in the end it really depends on your use case of these variables. Will they be used to tested against real dates, or do you mostly need them as links?

(PS! In my test data the T is defined like you did originally, and the L is like this last definition, but hopefully the explanations and images make sense)

2 Likes

An education. Takk.

And the Dataview now only needs to be this?

1. `=this.target_completion.week`
2. `=this.target_completion.month`
3. `=this.target_completion.quarter`
4. `=this.target_completion.year`

That seems to do the trick, yes, if you’re just wanting the links.

1 Like

Thanks. :pray: :student: :person_raising_hand:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.