I have been using IMPORTRANGE and QUERY extensively to connect all of my spreadsheets for a while now. But recently noticed that IMPORTRANGE and QUERY will not return proper data unless the source Sheet is open. Also, the data used to automatically update (every 30 min or so, whatever the default refresh rate is) in the background for IMPORTRANGE, but now it will only update if I manually open the Sheet and it will display "Loading...." before returning the data.
Is anybody else having issues with these two functions?
This answer explains the issue you encountered.
In summary:
It doesn't update when the sheet isn't opened.
Recalculation only happens when sheet is opened.
Functions that pull data from outside the spreadsheet recalculate at the following times:
ImportRange: 30 minutes
ImportHtml, ImportFeed, ImportData, ImportXml: 1 hour
GoogleFinance: may be delayed up to 20 minutes
Alternative solution:
You can use time driven triggers and update those values every N minutes/hours instead BUT you will have to create a script for that.
Everytime you trigger, you'd have to use setFormula on every cell you used your importrange and query.
References:
setFormula
Choose how often formulas calculate
Time Driven Triggers
Related
I have a Google Spreadsheet document with 15 sheets from which one has like 40 columns with ARRAYFORMULAS and other XLOOKUP and VLOOKUP functions from other sheets and is running slow with a delay that affects the way I can work with it.
Now, that sheet has only 30 rows and I would expect it to have like 50.000 at the end , but if it's working like this I don't know how I could handle more inputs into that sheet as it would be very hard to access it.
I've tried clearing the cache, site data and cookies from Chrome but it didn't do anything ... any suggestions on how I can improve this ?
I need the formulas in that sheet as some columns need to be calculated based on come new input and changes on other columns.
Simplified scenario:
Sheet Customer_Orders, has blocks of rows with each row having product code, count ordered, and size. Bunch of other stuff is looked up/calculated on the basis of these three tidbits. By the end of the season this sheet has about 5000 rows.
Sheet Raw_Inventory has start of year in the first 500 rows, and then does a query to Customer_orders. By season end this sheet has about 2000 rows.
Near as I can tell, this query runs every time I change one of the 3 fields in Cust_Orders.
Sheet Inv_Status is a pivot table that runs against Raw_Inventory, and again, I think that every time Raw_Inventory is modified, the pivot table is recalculated. (There are a couple of other pivot tables that use the same data.)
The result is that making a change on Cust_Orders can result in up to 2 minutes while the calculations catch up.
(Hardware: Mac Pro, 24 GB ram, 3.2 GHz, 4 core; Current version of Chrome running under Yosemite)
What I would like to do is one of the following:
Lengthen the time between updates.
Be able to recalculate sheet Raw_Inventory manually.
A partial workaround:
I've created a new sheet that imports raw_Inventory. This copy is used for the pivot table. ImportRange only runs every 30 minutes.
The next step will replace the query with 1 zillion simple assignment statements. I'm hoping that this will replace querying 3000 lines with querying a single line when I make a change in Cust_Orders.
There is no way to disable automatic recalculation in Google Sheets. One option is to replace the formulas by the values either by using copy/paste as value only or by using a script. The advantage of using a script is that it also could be used to add again the formulas when needed.
Related
Ho do I stop and start autoupdating in Google Sheets?
Formulas always recalculating when refreshing/loading spreadsheet
I had a similar problem, I solved it by creating an enabling cell and in that cell I put 0 or 1 and then I used that cell inside the formula. In such a way that:
A
B
1
enable formula
0
2
= if(B1=0; 0; complex_formula1)
= if(B1=0; 0; complex_formula2)
3
= if(B1=0; 0; complex_formula1)
= if(B1=0; 0; complex_formula2)
This way when I need to change the spreadsheet I disable formulas (putting 0 on A1), change spreadsheet and on end I enable formulas (putting 1 on A1).
It's not the best solution, but it worked for me.
This is not an answer to my original question -- how to control recalculation, but is a workaround, and ultimately a better solution.
Quick restatement of problem:
CustOrders pulled descriptions of inventory off of RawInv sheet.
RawInv updated from CustOrders. This wasn't quite a circular dependency, as RawInv only updated quantities from CustOrders. But it meant that anytime a change was made in CustOrders, RawInv needed to be recalcuated.
This was made worse by having one query per line creating descriptions.
The solution amounted to refactoring.
Another spreadsheet was created, CustSupport.
It kept RawInv and Trees -- the latter being the descriptions. It also had the master reference sheet for prices and round off tables. These two tabs are rarely changed, and are copied as needed to sheets that use them.
It imported a copy of CustOrders. Since this copy had no dependencies back to to main ordering sheet, I didn't have to wait for it to recalculate.
RawInv recalculated from this copy of CustOrders.
I did a wholesale replacement of Querys with VLookups. This required some rearrangement of columns.
ImportRANGE returns a #NAME error occasionally as it updates itself every 30 mins.
I took a look through Google Sheet Script Returning #NAME? but there sadly wasn't any solutions. The best guess at a response was about how google sheets loads custom formulas, but since =IMPORTRANGE() is a vanilla formula it shouldn't have a problem with that.
My formula is
=IMPORTRANGE("URLHERE",(A5&"!"&"D1"))
First the URL, then the final section allowing it to request data from a different sheet in the file for every line. I have setup the sheets that contain the source data to be called 1,2,3,4, ect up to 100 to accomodate for this.
I am trying to import data from a different sheet that has a custom script running to import JSON data. The JSON is imported perfectly and once a day a macro will run that updates the JSON values. I have a separate sheet that I don't want to run the script on, so I am using IMPORTRANGE to get the data from JSON imports. Every 30 minutes Importrange updates itself and it researches for the values. It would work fine for me for this to be once a day, however, I can't find a way to change that.
Most of the time it has no problems, occasionally it has a problem with a couple of the imports but most are fine. A couple of times it has hit #NAME on every single IMPORTRANGE.
I currently use =ImportRange to bring in some data from a public sheet I do not own.
However, it is a lot of data and importrange tries to refresh the data on every page access, and doesn't cache it locally.
Is there a script I can run instead to get the data via importrange, then hard code it into my own sheet and only update it once a week?
You can use the Google Sheets add-on called sheetgo, to automatically update your reference from another sheet. You can use 30 updates for free every month or pay for more updates
But I found this to be effective.
function refreshSheet(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet_name);
//Your operations on the sheet
Utilities.sleep(1000);
}
while(true){
Utilities.sleep(604800000);
refreshSheet();}
I have spreadsheet with two sheets: current_sheet and archive_sheet.
I also have a script (which I created) which removes data from current_sheet and appends it to archive_sheet once per month.
The sheets have an arrayFormula, and after every monthly move operation, cells with this arrayFormula wind up without any results - and I receive a warning message, indicating that I should press Ctrl+Shift+E in order to resolve the problem.
Once I've done so - the formulas work again. What I'm wondering is... how can I alter my script so that I don't have to provide this manual fix every month?
use a time driven trigger to run your script each month
Instead of using script to move your data each month, try copying the values, then clearing the original data and reinitialise the formula. Without seeing your formula and have a clear understanding of what your doing, im kinda punching in the dark.