How to refresh a dataview query

Basically, if you don’t change a dataview query, it seems to stay the same until you reopen the query. It seems like currently, it doesn’t refresh the query even if the refresh interval is set, nor if you call the Force refresh command.

This is troublesome, when developing and testing queries, so I therefore ask if you know a way to trigger the query again, besides adding/removing space (or other insignificant changes to the query), and switching from/to reading view.

This is mostly a problem when the query is almost completely defined, but you change the base data for the query to test various cases, or you change fields that the query is based upon, but still the query itself is not changed.

And yes, I’ve tried asking at github, with no response for a few days. But I kind of remember seeing someone in this forum having a nifty little trick to trigger a query refresh, but I can’t find it. So therefore this request, if some of you know a way to trigger a rerun of a dataview query, when the query hasn’t changed, but some of the underlying data has.

Update: I forgot to mention that I usually have a dual setup with one tab in editing mode, and the other in reading mode. So the query to be refreshed is already in reading view.

1 Like

Are you using a Dataview query language or a DataviewJS query? I’ve found that DQL queries usually refresh correctly when an underlying page changes, but sometimes DJS queries do not. I notice this regularly when I have a query that loads another script via dv.execute(await

Also, if you’re using indirect fields in a query (for example a value looked up from a page that is itself the result of another lookup), it seems like Dataview doesn’t always catch the change when the underlying page is updated.

I’ve found that switching between reading and edit mode doesn’t always force a refresh for DJS queries, but flipping back and forth from a previous page (e.g. using “Navigate Back” and “Navigate Forward”) does the trick.

1 Like

I use a hotkey to reload Obsidian and that usually prompts Dataview to refresh. Not ideal, I know.

Hopefully Datacore will bring some joy (but leave thousands of pages needing to be updated).


That sounds like a neat trick, but I forgot to mention that I’m usually having a dual view setup, one tab with source mode and one with reading view, and of course that’s the one I would like to refresh.

I also do have indirect fields, and stuff like that, which makes it harder for dataview to pick up on any changes. I also use dataviewJS a lot. So I’m not making it easy for myself.

I’m a little divided on Datacore, it does sound intriguing to get a new tool like that, but I’m a little sad as that mean that Dataview is most likely going to get a whole lot less attention, and it might mean that in due time it gets to be yet another abandoned plugins. And there are far too many of them already, it seems.

You’re triggering the “Force reload” with that hotkey? That’s a little longwinded for my taste. I would really like to just get it to redo the query.

1 Like

CMD R, assigned though macOS System Settings. Not ideal but …

In an older post, it was mentioned we can tweak the refresh interval, but that options seems to be gone. Or am I not looking in the right place?

By the way, this is easy to test when just showing the current time, including seconds and fractions:

`=dateformat(date(now), "HH:mm:ss.uu")`

Then switch between editing modes. The time is different(!) between Reading and Editing mode. And it only updates if you close & reopen the note or navigate back and to with the arrows.

Definitely not ideal, the great plugin needs some TLC. Or better yet, integration as a core plugin? :slight_smile:

1 Like

This …

1 Like

Okay, looks like I am actually losing my eye-sight as we speak. Thanks for the pointer. But the setting does not seem to matter at all.

1 Like

As indicated in my first post, it didn’t affect my issue at last. And just that is understandable since this is the timer after the files stop changing.

So I’m still missing a reliable way to refresh my unchanged query, when some of the related data changes, which is not picked up by the surrounding system.

I’ve now found that if I add a button to change the first line to itself again, it will refresh the query. That is if the button changes the first line in the code block from ```dataview to ```dataview, it forces a refresh.

Typical code used to achieve this:

name To dataview
type line(19) text
action ```dataview
replace [19,19]

Note that it does rely heavily on the line number of that first line, so if you change the text preceding the code block, be sure to also change the line number where it inserts the ```dataview text.

An image of the above code in use:

To turn on line numbers go to Settings > Editor > Show line numbers, and enable that.

Below is a larger showcase of how I use the same trick to also switch between a source view and the dataview view (even when in live preview or reading view).

Since this still is kind of a workaround, I’m leaving this post open for a proper and permanent refresh option of dataview queries.