# Embed /include dataview from other file

**URL:** <https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127>\
**Category:** Help\
**Tags:** dataview\
**Created:** [December 20, 2022, 5:01pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127 "2022-12-20T17:01:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_anh\_ngoc](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mr\_anh\_ngoc](https://forum.obsidian.md/u/mr_anh_ngoc)\
**Post date:** [December 20, 2022, 5:01pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/1 "2022-12-20T17:01:26Z")

</div>

### Things I have tried

referring to : [Reference dataview table - #7 by Saorsa](https://forum.obsidian.md/t/reference-dataview-table/34847/7)  
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:

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

```

the inline js query in this file further down is:

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

```

the file with the query (dv\_incl\_file.md) has the code:

```auto
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…?

---

<div class="post-metadata">

**Author:** ![mnvwvnm](https://forum.obsidian.md/user_avatar/forum.obsidian.md/mnvwvnm/32/9766_2.png) [@mnvwvnm](https://forum.obsidian.md/u/mnvwvnm)\
**Post date:** [December 20, 2022, 10:15pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/2 "2022-12-20T22:15:07Z")

</div>

Can you provide two or three sample notes to test?

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [December 20, 2022, 11:02pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/3 "2022-12-20T23:02:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mr\_anh\_ngoc](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mr\_anh\_ngoc](https://forum.obsidian.md/u/mr_anh_ngoc)\
**Post date:** [December 21, 2022, 3:47pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/4 "2022-12-21T15:47:48Z")

</div>

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

File: \_action\_1

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

```

project:: [[project\_1]]

File: \_action\_2

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

```

project:: [[project\_1]]

File: \_action\_8

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

```

project:: [[project\_2]]

File: project\_1

```auto
---
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

```auto
---
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

````auto
```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](https://forum.obsidian.md/u/mnvwvnm) already gave me advise…  
I set up a new vault only with dataview-plugin → also negative.

Obsidian Version v1.1.8,  
([mnvwvnm](https://forum.obsidian.md/u/mnvwvnm) has v1.0.3 and it works for him… )

I found this thread: [Dataview: reuse DQL queries?](https://forum.obsidian.md/t/dataview-reuse-dql-queries/44370)

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?

---

<div class="post-metadata">

**Author:** ![mr\_anh\_ngoc](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mr\_anh\_ngoc](https://forum.obsidian.md/u/mr_anh_ngoc)\
**Post date:** [December 21, 2022, 4:39pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/6 "2022-12-21T16:39:59Z")

</div>

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

 ![grafik](https://forum.obsidian.md/uploads/default/original/3X/9/f/9f0ab1d4a84d224e5aa8ac688d4a25c3c173f9e2.jpeg)

---

<div class="post-metadata">

**Author:** ![mnvwvnm](https://forum.obsidian.md/user_avatar/forum.obsidian.md/mnvwvnm/32/9766_2.png) [@mnvwvnm](https://forum.obsidian.md/u/mnvwvnm)\
**Post date:** [December 21, 2022, 4:52pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/7 "2022-12-21T16:52:20Z")

</div>

I hate to say this again… but never discuss a possible “bug” or debug things in Live Preview!  
I hate LP!!! 😡  
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:

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

````

---

<div class="post-metadata">

**Author:** ![mr\_anh\_ngoc](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mr\_anh\_ngoc](https://forum.obsidian.md/u/mr_anh_ngoc)\
**Post date:** [December 21, 2022, 5:02pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/8 "2022-12-21T17:02:44Z")

</div>

bang → works.  
but I should have thought of that too… but it doesnt seem so…  
😉  
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 🙋‍♂️

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [December 28, 2022, 5:03pm UTC](https://forum.obsidian.md/t/embed-include-dataview-from-other-file/50127/9 "2022-12-28T17:03:29Z")

</div>

Closed on December 28, 2022, 5:03pm UTC

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