Things I have tried
I have searched, and searched this Obsidian forum, and not found anything that leads to an answer.
The following threads come close, perhaps:
@scholarInTraining helped here, but I was unable to pursue their suggestion before the thread was closed and so couldn’t ask follow up questions.
What I’m trying to do
In summary: I want return all the tasks in my vault which are tagged with tags associated with the current page’s tag field.
I’m trying to get some help coding the following ideas into dataviewjs. I simply don’t know enough about javascript to make it work… I hope what follows, clearly communicates the logic of what I want to do, generally speaking from an abstract point of view.
Read this for context…
Imagine the current page, called cp
, belongs to an obsidian vault called V
. Pretend cp
has a field tags::
whose associated array of elements are #a
#b
#c
.
Thus, in the abstract cp
would look as follows:
tags:: #a #b #c
(Let’s say an arbitrary member of tags::
is called x
. This means means when I mention x
below, I’m just referring to one of #a
, #b
, or #c
in tags::
of cp
, and it really doesn’t matter which one.)
Also, imagine there is a set of tasks T
strewn throughout vault V
appearing randomly on V
’s pages . i.e. not in a predictable section on a given page v
. Imagine the text of the tasks is varied, and let it be true that most of these tasks are tagged.
For a given task t
in T
, the set of tags G
associated with t
is pretty open ended.
So, for example t
could be as follows where G = {#a, #b, #c, #d, #e}
:
- [ ] blah blah blah #a #b #c #d #e Example 1
Or, t
could be like this, where G = {#a, #s, #d, #f}
:
- [ ] blah blah blah and more blah #a #s #d #f Example 2
A subset of T
, let’s call it S
, is tagged with #a
#b
#c
, the array elements associated with tags::
in cp
.
An arbitrary task s
in S
might look like this, where G
actually (loosely speaking) equals tags::
:
- [ ] blah blah #a #b #c Example 3
Or, where tags::
is (loosely speaking, again) a subset of G
:
- [ ] blah blah #a #b #c #d Example 4
(It follows that the task in Example 1
is a member of S
because it is tagged with #a
#b
#c
. It has additional tags, but that is incidental. )
So far, we have a vault V
, whose current page cp
has a field tags::
whose associated array is #a
#b
#c
. It is also the case that some of V
’s pages have tasks on them, and some of these tasks, the set S
, are tagged (but not exhaustively) with #a
#b
#c
.
My question is this:
How do you query V
with dataviewjs (or dataview, if that’s possible) and return a list of s
in S
as defined above?
In other words, how do you return the tasks which are such that for each tag x
in tags::
of cp
, x
is also a member of G
(the tags associated with s
) ?
In summary: I want return all the tasks in my vault which are tagged with tags associated with the current page’s tag field.
I really appreciated any suggestions or thoughts. It seems I need to use a for
loop, but I don’t know how to implement them in dataviewjs. If it were python, I could code this, but I don’t know where to start with dataviewjs.
Thanks for any help.