Here's the modified Dataview query that displays all notes when search criteria are empty, while maintaining your filtering logic:
TABLE without id
file.link as Name,
tags as Tags
FROM "Notes"
WHERE
(defined(status) OR defined(rating)) AND
(length(toString([[hub.search]].status)) = 0 OR status = [[hub.search]].status) AND
(length(toString([[hub.search]].rating)) = 0 OR rating = [[hub.search]].rating) AND
(length(toString([[hub.search]].tags)) = 0 OR contains(tags, [[hub.search]].tags)) AND
!contains(file.name, "template") AND
!contains(file.name, "hub.")
SORT created DESC
Key improvements made:
-
Conditional filtering - Each search parameter now checks if it's empty before applying:
(length(toString(X)) = 0 OR ...)
This ensures empty criteria don't filter results
-
Improved field checking - Changed from string matching to proper field detection:
(defined(status) OR defined(rating))
(More reliable than searching frontmatter as strings)
-
Tag search fix - Changed to contains() for proper tag matching:
contains(tags, [[hub.search]].tags)
(Works correctly with Obsidian's tag lists)
-
Syntax cleanup:
- Fixed broken
SORT command
- Added proper capitalization to
DESC
- Improved spacing for readability
How it works:
- If any search parameter (status/rating/tags) is empty in
hub.search, that condition will be ignored
- Only notes that have either status or rating defined will show
- Template/hub files are always excluded
- Sorting remains by creation date (newest first)
Note: This assumes your hub.search note has frontmatter fields called status, rating, and tags. The query will work with blank/empty values in these fields.