Fetching single line of text from another note with inline Dataview?

OK, I would think that this can be done, but I can’t figure it out…

Suppose I have a note called “Values”. In that note is a rolling list of values in this format:

[[YYYY-MM-DD]]:: Numeric value here

So something like this:

[[2023-10-10]]:: 145
[[2023-10-09]]:: 120
[2023-10-08]]:: 112

And so forth. The link is pointing to the daily note of that date. In the daily note I would have a section that would just list the numerical value for that date. So in our example, the daily note for 2023-10-10 would have something like this:

Value: [Numerical value from Values.md here]

I would prefer this to be an inline query, as it would for the format of the page better. Also, the links from the Values-note to the daily note are not a requirement, so instead of [[YYYY-MM-DD]]:: it could be just YYYY-MM-DD::

Can this be done? If it can, how? This seems like very basic thing, but I’m stumped.

I just realised that I have asked something similar earlier:

But there is a slight difference: In the earlier example it was just “regular” dataview query that can return several values. This time I would need to return just one value, and I would prefer an inline query.

But, in the meantime I decided to handle my request using the approach outlined in my earlier forum post. But I can’t get it to work. Which is weird, as the format in both cases is basically same: a rolling list of entries, each entry linking to a daily note. I started from the beginning and listed every entry along with outlinks:

TABLE WITHOUT ID item.text, item.outlinks
FLATTEN file.lists as item
WHERE file.name = "Values"

And it returns nothing. I even changed the format of the entries to match the one in the earlier discussion. If I do the exact same query (Modified for different note of course) for Log.md, it works fine. So I’m again stumped…

OK, I figured out why it wasn’t listing any entries. In the earlier file each entry had a bullet-point, in the “values”-file they did not. SO I could now list the value as a Dataview list. But I would prefer to handle this inline…

Try this. Seemingly, you can’t use a link like [[2023-10-10]] as the key of an inline field, so I changed it to a raw string.

Values.md:

2023-10-10:: 145
2023-10-09:: 120
2023-10-08:: 112

Daily note:

Value: `=[[Values]][this.file.name]`

However, my guess is that Dataview is designed for the opposite use case in mind. I mean, data lives distributedly across various notes in your vault, and you write a query to collect that information in one place.
So in this case, the numerical value for each date is stored inside the daily note for that date, like so:

2023-10-10.md

Value:: 145

2023-10-09.md

Here's today's data: [Value:: 120]

2023-10-08.md

Today's value is (Value:: 112)!

Values.md (assuming you put your daily notes in a folder named “Daily notes”)

```dataview
TABLE Value
FROM "Daily notes"
```

That being said, you are totally free to use a tool for a different purpose from its developer’s intention.

First of all, thank you for your time and effort :slight_smile:

Try this. Apparently, you can’t use a link like [[2023-10-10]] as the key of an inline field, so I changed it to a raw string…

Value: `=[[Values]][this.file.name]`

Yes, that did it! Getting the formatting right sure is difficult…

However, my guess is that Dataview is designed for the opposite use case in mind. I mean, data lives distributedly across various notes in your vault, and you write a query to collect that information in one place.

Yeah, I can see that. Upside of having the values in one file is that I can add to the file using other tools, like Shortcuts on iOS. Adding those values to middle of daily note would be way more difficult. Having them in single file means I can just add new line to the file and be done with it, instead of adding the info to a specific location in a new file.

Ahh, now I see your intention! Thanks for clarifying.

Sorry for the late reply, but I think I would switch this around, and use a decorated task in the daily note to describe the value, and then have a query picking up all the values in the “Values” note.

Are you likely to have many values like this, I would opt for adding a value type into the task, and if not I would possibly just use a dedicated status characters for the value in question. Here are examples showing the respective options:

- [v] 145
- [v] [type:: someType] 120

These could then easily be queried in the “Values” notes using a query like:

```dataview
TASK FROM "daily notes"
WHERE status = "v"
    AND type = "someType"
```

Remove the last line, if not needed. This query would produce a list of all values, and if you click on the number itself you’ll go back to the daily note where the value was defined. Using a dedicated status character, like v in our example, you could also format the value entry using CSS.

GIven what you would like to do with the values in the posterity, you might also want to consider doing something like:

- [v] (value:: 112)

Which would render the value within a field in the task, allowing for easier querying and calculation on it in table/list queries later on. It would also allow for comments related to why this values is as is (without it corrupting the value itself).


My main point is that you could use tasks in the daily note to list the values, and since tasks have links back to their origin you’ll get the link you’re requesting. Tasks in Obsidian can be also styled in various ways, making them visually interesting, and lastly they’re easily retrievable from Dataview for querying.

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