Using dataview, how can I make it so my table query links to the actual inline metadata, rather than just the file?

What I’m trying to do

I want the ability to add an inline metadata field in various notes, to mark where I had a question about something, and also have a table in another file that collects all instances of those tags, with a link to where they are in their respective files.

Things I have tried

I have this mostly done using dataview, but I’m missing one part. Right now here’s my dataview table:

dataview
TABLE open_question as "open question"
WHERE open_question

and an example of what I’d do in a note would be:

 [open_question::How many burgers could a lion eat?]

// blah blah, lots more text

[open_question::If the moon is made of cheese, what milk was it made from?] 

this mostly works: it creates a table with “file” in one column (that has a link to the file with an open_question metadata field) and “open question” in the other column (that has the text of the question; if there are multiple fields in the same note like in my example, it forms a nice bulleted list of them).

That’s good. But the link is just to the file, which are often pretty large. I’d rather it be so that the text of each question is a link to the field itself, so it’ll jump to where in the file it is.

How can I do that? is it possible with dataview or would I have to use JS? thank you.

1 Like

So basically you’ve got these kind of links:

  • To the page. e.g. [[MyNote]]
  • To the header, e.g. [[MyNote#MyHeader]]
  • To a block, e.g. [[MyNote#^myBlockId]]
  • The indirect task link

The two first will give you the right file, and somewhat close (if you know which section/header its under). The third variant will get you to the correct block, but it depends on the myBlockId to be defined for that block. However, it’s not very easy to get the header or the blockId related to where the inline field was defined (unless the field is defined within a list (or task list)).

This is one of many reason why I like the task decoration (or custom checklist), since if you list a task through a query you can click on the task text, and get transported right back to the task definition. In other words, the indirect task link.

So my suggestion is to change your markup to something like:

- [?] How many burgers could a lion eat?

And then the query becomes:

```dataview
TASK WHERE status = "?"
```

Now you can click on the task text, and get transported straight back to the exact line where you asked that question. Depending on which theme you’re running (like Minimal or LYT and some others), this task could already have a nice question mark in front of the question. If not, it’s easily doable using some custom CSS.

If you want another character or icons, that’s also an option, and personally I use this to track my walking trips, calls, appointments, sudoku’s I’ve solved, and loads of other stuff.

thanks, this seems potentially promising. I guess I don’t love having to make random lists, but it wouldn’t be too bad. I tested with your example and in terms of the linking it does exactly what I want.

One question though: I have questions on different topics, and want tables (in different notes) for each topic. I was hoping I could do something like

- [questions_shrubberies] when does a shrub become a tree?

and

TASK WHERE status = "questions_shrubberies"

but it appears not to work. I guess you mean that they have to be single symbols only?

Custom checkboxes work only with one symbol in checkbox. But you can add additional tag for the task, like this:

- [?] when does a shrub become a tree? #shrubberies

And then:

TASK
FROM #shrubberies
WHERE status = "?"

Or, if you only use this tag in questions, you can even omit status:

TASK
FROM #shrubberies

Inline metadata instead of tags works too.

1 Like

I’m not sure why, but I’ve often chosen to do stuff like:

- [?] (topic: Shrubs) When does a shrub become a tree?

So I’m more used to doing this with metadata, and not tags, but as said I’m not sure why I’ve opted for this variant.

But as reaty explained it’s only one character in the custom checklists status. You can however opt for other different characters, in case you want to use tasks for similar stuff. Like if you wanted to use these kind of tasks to document facts, or trivia, or something entirely else.

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