Using multiple tags on a single note with Dataview

Hello All,

Obsidian noob here. I have a journal where I have one note per year, so each note contains several entries (several per week.)

I’d like to use Dataview to query my entries, but I don’t think I can do that with standard tags since I have several per page. Plus, tags become unwieldy after a point.

Is there an alternative to using tags? I would like to add metadata to each entry if possible.

Thanks!

What I’m trying to do

Well, I don’t see any argument against using tags. If you format your entries as lists:

  • Today I did a thing. Then this happened. …

you can do a section search with dataview.

Try something like:

TABLE link(L.section,"jump to paragraph") AS Link
FROM #watching 
FLATTEN file.lists AS L

The resulting link should take you directly to “2-5-23”.

After some more searching, I believe what I should use is inline metadata.

What I want to do

Use Dataview to query a single note with 100+ tags in it, but have it delineate between entries.

Using my screenshot as an example, if I query #watching (or :: watching) I want the query to return only my entry for 2-5-23.

Also, if I should use inline metadata, where should I place the :: watching tag?

Thanks

First of all, tags are connected to a scope. The two basic scopes are the page and lists. You’re first example is using the page scope, so even though your tag is located near the “2-5-23” heading, it’s still within the scope of the page, so it’s just as close to the “2-6-23” heading.

Second, I’m all in favour of using inline fields (or metadata), but they have the same scoping issue that they’re either connected to the page or to lists (and with list tasks are included by the way). In addition an inline field can’t contain another inline field, so it might be hard to collate all the information you want into one section.

So how would I adress this, I would use lists to utilise the other scope available:

- 2-5-23: (title:: This event happened today) #watching
  - The first thing you did in all its glory

- 2-6-23: (title:: This other event happened today) #funny #work
  - All about this funny other work thingy

Using a syntax like this would lend your data easily for querying by dataview, and you could extract either the entire notes using childrens, or just titles. You’re not going to be able to link directly to that particular section, though. As a list item is not a link target, so far.

You could possible use tasks, as you can in some cases link to them directly, if you preper the visual appearance of it correctly. Using tasks would also allow for the introduction of icons both for the visual pleasure of it, but also as an aid to query the tasks related to a particular topic (and potentially remove the need for some of the tags).

A final note, is that “2-5-23” a date reference, or just some random numbers? If a date, I’ll think you’ll thank yourself if you changed to using iso dates, like “2023-02-05” later on, as they’re much easier and reliable to use in queries and so on.

Thanks so much. The reason why I don’t just make lists or separate notes is I have 12 years of journal entries (one big file per year) so it would be a laborious undertaking to go create lists for every entry.

RE: my date format, that’s how I started doing it 12 years ago. I agree YYYY-MM-DD is better.
I hope I can figure out some way to do a find/replace all but that will be tricky. I wonder if there’s some kind of fancy regex magic that could accomplish that.

Ouch… I see why changing to a better would be a little tricky, or labour intensive.

But could you show the actual markup for that example of yours? And are your entries fairly consistent with that markup?

And how would you feel about doing regex replacement on your files, to try shaping/knocking it into something slightly better?

(I’m thinking using VS Code and doing some magic from within its very capable regex engine)

Sure. Here it is. It looks a little different than the previous screenshot. (The date used to be #### but then I changed the color scheme in the css file.)

I think I’ve figured out a way to fix the date using the find/replace all feature.

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