Embed /include dataview from other file

Things I have tried

referring to : Reference dataview table - #7 by Saorsa
I want the same query to use in multiples files and place in only one place to easily made future changes…

so my frontmatter of the file, where I want to embed the including file (with the dataview query) looks like:

---
key1: valueA
key2: valueD
type: action
---
project:: [[projekt_1]]

the inline js query in this file further down is:

`$=dv.span(await dv.io.load('dv_incl_file.md'))`

the file with the query (dv_incl_file.md) has the code:

TABLE 
key1, key2, due-date
FROM "folder/folderA"
WHERE type = "action"
AND project =this.project

but all I get in the file, where I call the included file(dv) is:
‘-’
where did I wrong…?

Can you provide two or three sample notes to test?

I would suggest looking into dv.view(), which in addition to hiding/containing your dataview code, also can accept parameters to tweek your queries.

One of my use cases for such a query is to build a navigation header for my (seldomly) daily journal notes, based on existence of entries. And with this function, I only have a single line within my daily journal notes.

1 Like

Thanks for your replay.
i did another try with more simple data/notes:

File: _action_1

---
type: action
dat-beg: 2022-12-20
dat-end: 2022-12-20
state: 2
---

project:: [[project_1]]

File: _action_2

---
type: action
dat-beg: 2022-12-20
dat-end: 2022-12-20
state: 1
---

project:: [[project_1]]

File: _action_8

---
type: action
dat-beg: 2022-12-01
dat-end: 2022-12-02
state: 2
---

project:: [[project_2]]

File: project_1

---
dat-beg: 2022-12-20
dat-end: 2022-12-22
type: project
state: 3
---

$=dv.span(await dv.io.load("dv_incl_ProjFile.md"))

File: project_2

---
dat-beg: 2022-12-27
dat-end: 2022-12-29
type: project
state: 1
---

$=dv.span(await dv.io.load("dv_incl_ProjFile.md"))

File: dv_incl_ProjFile

```dataview
TABLE dat-beg, dat-end
WHERE type = "action" AND project = this.file.link
SORT state ASC, dat-beg DESC  

but all I get is:
‘-’
mnvwvnm already gave me advise…
I set up a new vault only with dataview-plugin → also negative.

Obsidian Version v1.1.8,
(mnvwvnm has v1.0.3 and it works for him… )

I found this thread: Dataview: reuse DQL queries?

but I dont get through.
i tried to change the call of dv to

$=dv.view(await dv.io.load('dv_incl_file.md'))
______^^^^^^
also renamed the file to dv_incl_file.js
→ negativ
is it a bug possibly?

I tried it on a Samsung S7+ tablet with Obsidian v1.41 (API v1.03) also only dataview plugin installed:

I hate to say this again… but never discuss a possible “bug” or debug things in Live Preview!
I hate LP!!! :rage:
Change the render to the Reading view!

Because inline queries in LP are buggy!
If you like to use LP, then it’s better use a codeblock:

```dataviewjs
dv.span(await dv.io.load("dv_incl_ProjFile.md"))
```
1 Like

bang → works.
but I should have thought of that too… but it doesnt seem so…
:wink:
it’s high time for me to take a break

thanks to your efforts, and don’t let spoil your mood because of my stupidness

have a nice Christmas all together :raising_hand_man:

2 Likes

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