Simple include in dataviewjs not working


Not sure what I’m doing wrong but I can’t get the include function to work on any data stored in arrays, such as list all files where folder path includes “xyz”.

Things I have tried

For instance, what bobkitz posted on: Dataview - All tasks not completed - #11 by mnvwvnm

            .file.where(f => !f.path.includes("foldernamehere")
            .tasks.where(t => !t.completed))

Only gives me an error message.

Any idea why?

And just for clearity, yes I know the example lists not completed tasks which is not it a specific folder, but I have tried the “include” function in many different without getting it to work.

In this expression, includes(<thing>) it search for one specific <thing> in each file (where file is the array, not the <thing>).

It’s impossible to guess what’s your case.

But your code have an error: it’s missing an “)” at the end of the second line ...!f.path.includes("foldernamehere"))

If a specific folder, use the filter in dv.pages(): dv.pages('-"myfoldername"')

Thanks for your reply.

So one of the things I’m trying to do:
For each research project I’m working on I have a separate file which all include task lists. In addition I have two folders, called “meetings” and “notes”, which ofte also includes task lists. To keep track of everything that is going on and not forget tasks from previous meetings I have a “research overview” file, and in this file I would like to list all not completed tasks within this folder or subfolder. I have other folder that I do not want to include. To make It clear the structure is something like this:


  • folder A
    • meetings
      • meeting 1
      • meeting 2
    • notes
      • note 1
      • note 2
    • index file
    • project file 1
    • project file 2
  • folder B
  • folder C

So I would like to make a dataviewjs call within the index file to only include tasks within folder A including subfolders/files.

What I thought would work was:

            .file.where(f => f.path.includes("folder A"))
            .tasks.where(t => !t.completed))

Oh yey, after reading this… I thought the “extra” ending bracket on the last line would close off the call but realized you were right and I was just missing an “)”. In any way, thanks alot! Its working. Feel pretty stupid :grimacing:

Reading your explanation, you just need to define the source in dv.pages()

	dv.taskList(dv.pages('"folder A"')
            .file.tasks.where(t => !t.completed))

Hi again,

Thanks for the suggestion. For some reason what you posted with including the folder name within dv.pages(‘“folder name”’) does not work here. But since the other method did I’m happy. Have a nice day and thanks for your great contributions!!

1 Like

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