Display copy of dataview table in another note?

What I’m trying to do

I’d like to have a dataview table in one note, and have that same table display in another note.

Simply copying the query to the other note is not good for my purposes, since I need these tables to appear across multiple notes, so changing the source table query would require me to propagate the changes to many many notes, which is impractical.

Things I have tried

I know that one can include the entire contents of one note in another by using <%tp.file.include(“[[Note Name]]”) %>, but even if I did get this to work with a single dataview table, it would not be appropriate because I essentially need changes in the source table to mirror in all other notes.

Please help! Thanks so much!

I’m away from my laptop at the moment to check if dv tables can be embedded as normal code blocks (I’ve never had the use-case), but if no, there may be an easy solution. Are we talking a few tables or many many different tables?

Because if you need just a few, and embedding them as code blocks isn’t possible, then I’d consider either putting the dv table in its own note, then embedding it as a note, normally. If you have many different tables, this will be annoying. Alternatively, you can think of using a DB Folder (see DB folder community plugin) to give you a note per table per se, but dynamic, as apposed to static in the note. Then you could again embed the DB folder and have much more control over its data apart from viewing.

If you need many different tables in many different notes, you don’t want to go the DB folder route, and embedding it as a code block isn’t in fact possible, then I don’t know of a way unfortunately.

In the answer below I discuss in a slightly different setting how to execute a DQL query which is in another file:

The gist of it is to do something along the lines of:

dv.execute(await dv.io.load("some/folder/myDQL.md"))

Where the myDQL.md holds the bare DQL query, not the code block fences or nothing else except the pure query.

In many cases, I do however believe it to be a better option to do build a dv.view() query, either consisting of almost a pure DQL query or transforming it into a dataviewjs query. There are advantages and disadvantages to either method.

1 Like

Cool, that’s a very interesting solution for me too. Thanks.

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