Run query periodically

I can see that can set a query to run periodically through advanced settings. However, this then always runs periodically. How can I dynamically start the query (and then run periodically) and stop the periodic running.

there is no native way to do this, but you can use this workaround:-

Set a temporary state variable to determine when this query is enabled/disabled and in between if the option to run periodically is set, it would do so.