Changed the DQL to dataviewjs, but it didn't work

I just tried changing the DQL to dataviewjs, but there seems to be something wrong with the incoming link [[WIP]] and [[Plan]]

table without id SelfLink as Link, ToDo, Scale, StartDate, DueDate
from [[WIP]] or [[Plan]] and "Work/Project" or "Personal Management/ToDoList"
flatten (DueDate - date(today)) as DueDate
where FinishTime = null
sort StartDate asc
dv.table(['name', 'ProStatus', 'DueDate', 'ToDo'],
	dv.pages('[[WIP]] or [[Plan]] and "Personal Management/ToDoList" or "Work/Project"')
	.where(p => p.FinishTime == null)
	.map(p => [
		p.file.link,
		f(dv, p, "ProStatus"),
		f(dv, p, "DueDate"),
		f(dv, p, "ToDo"),
	])
)

Hi @traxxomniac, welcome to the Obsidian community!

Your FROM syntax seems fine. I tried a similar query in my vault and it was able to find the incoming links. I do notice, however, a difference in the query itself that might be causing your problem.

In your DQL, you have:

from [[WIP]] or [[Plan]] and "Work/Project" or "Personal Management/ToDoList"

…but in your DataviewJS you have:

dv.pages('[[WIP]] or [[Plan]] and "Personal Management/ToDoList" or "Work/Project"')

You have your ANDs and ORs in different positions. Because ANDs are usually executed before ORs, this means the two queries may pull very different result sets.

In your first set you have:

  • incoming link to [[WIP]] OR
  • incoming link to [[Plan]] AND in folder “Work/Project” OR
  • in folder “Personal Management/ToDoList”

In your second set you have:

  • incoming link to [[WIP]] OR
  • incoming link to [[Plan]] AND in folder “Personal Management/ToDoList” OR
  • in folder “Work/Project”

I recommend trying changing the DataviewJS statement to match the DQL, e.g.:

dv.pages('[[WIP]] or [[Plan]] and "Work/Project" or "Personal Management/ToDoList"')

Hope this helps!

Craig

1 Like

In addition to what Craig says here, I would just like to mention that you can use ( ... ) to group the various conditions together, so I’m kind of imagining what you’re really looking for is something like:

( [[WIP]] or [[Plan]] ) and ( "Work/Project" or "Personal Management/ToDoList" )

Which would read (and translate) as:

  • Incoming links from either [[WIP]] or [[Plan]],
  • and
  • Folder equals to either “Work/Project” or “Personal Management/ToDoList”
2 Likes

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