Dataview Question : Filtering using WHERE shows empty results

Things I have tried

What I’m trying to do

I am trying to create a management system with inline tags in Dataview.

The data I have is as follows :

- [title:: Note Down Expenses]  [tag:: Money]  [status:: ToDo]
- [title:: Send Weekly Expenses]   [tag:: Money]  [status:: Done]
- [title:: Test]   [tag:: Money]  [status:: Done]

I am able to fetch the data from the fields using DataView. But, when try to filter with the WHERE clause, I am getting an empty table.

I tried different variations. But, none worked.

TABLE WITHOUT ID title, status, tag
FROM "Tasks"

Variations I tried

TABLE WITHOUT ID title, status, tag
FROM "Tasks"
WHERE status="Done"
TABLE WITHOUT ID title, status, tag
FROM "Tasks"
WHERE status = "Done"
TABLE WITHOUT ID title, status, tag
FROM "Tasks"
WHERE status == "Done"
TABLE WITHOUT ID title, status, tag
FROM "Tasks"
WHERE status != "Done"

I know that there is a built in task management system. But, I would like to customise it a lot and add some more things.

Please help me understand what I am doing incorrectly. Thank you.

If you are setting values like “title” and “status” multiple times in the same file, then dataview will have their values as a list. E.g. for your example 3 lines, status for that file will be ["ToDo", "Done", "Done"]. So you can see why that list does not match on equality with a single value.

You can embed annotations like this in tasks and still make a table if you want! You may need to change some annotation names so that they do not conflict with the ones implicitly collected by Dataview. When making your table of tasks, FLATTEN file.tasks as "Tasks" will likely be a useful line.

Good luck!

1 Like

Thank you so much for explaining that the results were an array. I used DataviewJS to get the result I wanted.

dv.table(
	["Title", "Status", "Tag"],
	dv.current().file.lists
		.where(
			k => k.status != "ToDo"
		)
		.map(
			k => [k.title, k.status, k.tag]
		)
)
1 Like

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