How to hide "Dataview: No results to show for list query."

If a dataview query is empty (list or table), there’s a very big block that takes up a lot of screen real estate (at least 8 lines worth) with the single statement:
“Dataview: No results to show for list query.”

For example, I have a query that is simply:

    LIST
    FROM #this_week 

How can I suppress this?

I’m interested to know if there’s another way, but it’s easy with a dataviewjs query:

```dataviewjs
const notes = dv.pages('#this-week')
if (notes.length) dv.list(notes.file.link)
```

That will only show the list if there are matching notes, otherwise it will display nothing at all. You could change it to display some placeholder text if you like.

3 Likes

Just to add on to AlanG’s suggestion, an example for the placeholder would be one more line in the dataviewjs

else dv.paragraph("No results found!")

(remove the backticks around this when copy-pasting)

2 Likes

Apologies - you’ll need to change it to #this_week with an underscore to match your tag.

1 Like

Thank you, that worked, of course (I did change the tag to an underscore).

I wish my javascript was better. :slight_smile:

1 Like

If you haven’t already, you might try turning off “Warn on Empty Result” in Dataview settings:

1 Like

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