How can I disable automatic recalculation on google sheets? - google-sheets

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.

Related

Preventing API edits from breaking arrayformula columns

I have a Google Sheet that I'm using as a database for a an app I am building in AppSmith. Really just an interface for people to work with the sheet in a controlled manner.
I'm using the Google Sheet because I'm familiar with layering formulas to make it work the way I want it to work. I have a number of columns that start with an ARRAYFORMULA that gives the name of the column in row 1, blank in blank rows that should be blank, and some programmed information in other rows.
This works great as long as I am working from the spreadsheet or reading/adding rows from the app.
However, when I try to edit the row from the app, the API update will take the "50" that it sees in the column and actually put "50" in the cell, breaking the arrayformula.
Is there any way to prevent API calls from actually editing that column? Or to automatically clear the cell and let the arrayformula expand again?
I found a temporary workaround to push "" for the column(s) I know are arrays, but it seems vulnerable to complications if I add other array columns later, or want to make another form in the app that also updates the sheet.
As a "rule of thumb", avoid having formulas on sheets being used as "databases" (top row used for field names, 2nd row and below used for data). If you really need to use formulas in the spreadsheet instead of doing the calculations on the "APP", add them on a "mirror" sheet.
This is a common recommendation when using ARRAYFORMULAS to do calculations with data comming from Google Forms.
If you think that creating a "mirror" sheet might cause more problems than benefits, if your "APP" is able to limit the number of columns being edited, put the formulas to the right of the last column linked to the app.
Related
Make Google Spreadsheet Formula Repeat Infinitely

Error "Result was not expanded automatically, please insert more rows": how to add rows automatically?

I use an ImportRange formula to get data from multiple tabs into single one. The formula looks like
=QUERY({IMPORTRANGE("123","B1!A2:D");IMPORTRANGE("123","B2!A2:D")},"where Col1 is not null", 0)
Is it there a way to add rows to table automatically if they are needed? With formula or setting - not by app script.
I had the same problem
Added another "arrayformula" to my original formula:
=INDEX(QUERY(...))
Made some tests and appeared all array-like formulas will add new rows automatically, including query. This means adding a new array function to your original formula will force the engine to recalculate again and add new rows. In general, this case looks like a bug / not expected behavior. The reason may be in the limit of resources the formula has, and it stops the work if calculations are heavy.
Limit test: Sequence
This formula will work:
=SEQUENCE(50500)
This will produce an error:
=SEQUENCE(50501)
After you add a new row manually, the formula works again.
Adding new formulas like INDEX(SEQUENCE(50501)) does not fix the error.
Limit test: array-like functions
I've also tested these functions:
QUERY
{Array}
SEQUENCE
Offset
Sort
Index
ArrayFormula
All of them stopped working after row 50501 including.
Possible Script solution
Possible to get the number of rows from the original formula.
=ROWS(SEQUENCE(50501))
Next, create a trigger to execute every N minutes to add new rows to your sheet.
Source
My Sample file with tests
All tests were made by date and in my environment. Your own tests may vary.
The sheet pulling the data (importrange) from another sheet does not have sufficient rows to display the data. Add more rows to the sheet - this solution worked for me. Ideally, this should have happened automatically, but it did not.
Refer:
https://support.google.com/docs/thread/4985024/error-in-gsheets-result-was-not-expanded-automatically-please-insert-more-rows-4

Adding to a cells value based on two other cells

I'm wondering how I would go about adding to a cell based on two other cells.
For example, I'm creating a Google Sheets document to track profit & loss on certain things in an online game I play.
I'll try to explain this as best as possible.
If cell B71 is equal to the string in cell B7, increase the value in cell D71 equal to the number in cell D7.
However, the values will need to be compared to various other things depending on the item required.
For example, the string in cell B7 might change depending on what specific type of item is needed for that day as it does change daily.
I have cells near the bottom of the sheet which list the different type of item which will show the total amount of items used in that month.
I've tried to explain this a little better as requested below
I'm trying to make a spreadsheet that keeps track of the quantity of a specific item I use in a game for a daily task. This task can be done daily, and to keep track of profit & loss, I have created a spreadsheet to keep track of this.
So, each day, there are three different types of items (runes) that can be used in the machine to create an item called 'Vis Wax'. As Runes are cheap, creating the vis wax can generate a good profit. (I love working with data, hense the spreadsheet.
The image above shows what a daily section looks like. I input each type of rune (has to be 3), input the quantity used and the amount each rune is worth to create the total cost under Total.
Further down below, this table has been created
This will keep track of each rune and the amount used during that month.
So with that said, I'm looking for a solution so that if Air rune is entered in ANY of them slots with the QUANTITY used, it'll update that table accordinly (as well as the other runes that are used too). I've tried nested IF statements, but don't seem to have any luck. With the amount of checks that seem to be happening, I can't seem to find a working solution. As Air Rune might be in slot 1 one day, then slot 3 the next day. So it seems each cell in the Quantity Table will need to compare EACH cell in the daily section, to each rune type that can be used.
Hopefully that has explained it a little better.
Spreadsheet Link
https://docs.google.com/spreadsheets/d/1sYLpZJ46IpNk52gxMoJOIZsOCWToLkC4FF83RBncCf0/edit?usp=sharing
I would suggest you to use a different structure and take all the data from one day in one column, something like this:
In this way you will be able to extend the days keeping the formulas in a really simple way. Below, I will explain some useful formulas that you can use to lighten your work:
Day: =text(DAY(B2),"dddd")
Rune type: Check Data validation to create a drop-down list of your rune types
For counting how many runes have you used you can use SUMIFS function. It returns the sum of a range depending on multiple criteria. In your case, you need apply it three time per rune, as you can have the same rune in three different places. You see it with the following image:
The formula is: =SUMIFS($B$8:$H$8,$B$7:$H$7,A25) + SUMIFS($B$12:$H$12,$B$11:$H$11,A25) + SUMIFS($B$16:$H$16,$B$15:$H$15,A25). In this way you only need to write it once and you can fill the rest of the runes just dragging the mouse. If you need more days just change the column H with the last column that you want to take.
I assume that with all this information you can also keep track of your monthly statics easily. I suggest you to create a different sheet for each month.
I hope that my answer was useful, let me know if you have any doubt.
George, I agree with #fullfine, your data structure does not seem ideal for data analysis. And it doesn't seem that efficient for data entry either, with the sideways scrolling (at least on my screen).
But I recognise that you might not want to change it, perhaps having specific reasons for that layout, and having invested time in it. So I offer this formula as an alternative, which basically pulls the needed cells from your existing sheet, and comes up with the totals you'll need.
=QUERY(QUERY({B7:D9;G7:I9;L7:N9;Q7:S9;V7:X9;AA7:AC9;AF7:AH9;
B20:D22;G20:I22;L20:N22;Q20:S22;V20:X22;AA20:AC22;AF20:AH22;
B33:D35;G33:I35;L33:N35;Q33:S35;V33:X35;AA33:AC35;AF33:AH35;
B46:D48;G46:I48;L46:N48;Q46:S48;V46:X48;AA46:AC48;AF46:AH48;
B59:D61;G59:I61;L59:N61},
"select Col1, Col2, Col3*Col2 where Col1 <>'' order by Col1 label Col3*Col2 '' ",0),
"select Col1, sum(Col2), sum(Col3) group by Col1 label sum(Col2) '', sum(Col3) '' ",0)
The same formula can be used for each month, since it always totals all 31 days, even if the month has fewer days.
For your Rune table in the Statistics sheet, you only need the firsts two columns, so you could delete the "sum(Col3)" from the last select statement.
For your smaller financial table, you would take the sum of the Col3 produced by the above formula, ie. the total value of all the runes used. A similar formula would be used to collect the count of the wax produced, its value, and the profit/loss for each day. This would let you complete the financial table.
If you do decide to go with this approach, and want any help with completing the tables, or the formulas, please share your sheet so "anyone can edit it", to make it easier for me to assist you.

Using a Named Range to identify worksheets to use a SUMIFS on a to add an array of data

Below is a sample of the Google Sheet I'm working on:
https://docs.google.com/spreadsheets/d/1LDsfn_FMdUSfuFZAyuXf5gdlOSN9yLqhT1RY8aX7Nfs/edit?usp=sharing
On the spreadsheet Team Totals, I'm trying to calculate all the sales based on the date, the type of sale, and the program type starting from Row 27.
The problem I have run into is that the Named Range, Consultants, only pulls the data from the first cell of the Named range (Octo). What I want is for a formula that will pull the data of the selected range from each entry in the named range and sum them together.
For reference, I put what the proper values should be starting from Row 33.
The closest example I have seen was from this website: https://www.got-it.ai/solutions/excel-chat/excel-tutorial/sumif/sumif-across-multiple-sheets
However, I get the same problem that only the first cell in the named range gets pulled.
I feel like I'm missing something simple, but I have been bouncing it around my head for hours and can't figure it out. Any help is greatly appreciated.
So after trying to figure out a way not to use an iterative process, I folded and did this:
=arrayformula(SUMIFS(INDIRECT("'"&$B$4&"'!F6:F100"),INDIRECT("'"&$B$4&"'!D6:D100"),$B$2,INDIRECT("'"&$B$4&"'!E6:E100"),E$27,INDIRECT("'"&$B$4&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$5&"'!F6:F100"),INDIRECT("'"&$B$5&"'!D6:D100"),$B$2,INDIRECT("'"&$B$5&"'!E6:E100"),E$27,INDIRECT("'"&$B$5&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$6&"'!F6:F100"),INDIRECT("'"&$B$6&"'!D6:D100"),$B$2,INDIRECT("'"&$B$6&"'!E6:E100"),E$27,INDIRECT("'"&$B$6&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$7&"'!F6:F100"),INDIRECT("'"&$B$7&"'!D6:D100"),$B$2,INDIRECT("'"&$B$7&"'!E6:E100"),E$27,INDIRECT("'"&$B$7&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$8&"'!F6:F100"),INDIRECT("'"&$B$8&"'!D6:D100"),$B$2,INDIRECT("'"&$B$8&"'!E6:E100"),E$27,INDIRECT("'"&$B$8&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$9&"'!F6:F100"),INDIRECT("'"&$B$9&"'!D6:D100"),$B$2,INDIRECT("'"&$B$9&"'!E6:E100"),E$27,INDIRECT("'"&$B$9&"'!A6:A100"),$A41))
This formula allows me to cut and paste it to various cells easily, and does the job I need it to, while still using the indirect reference so I can change names without breaking the formula (granted I change the worksheet name as well).
I will need to edit this to include all possible worksheet amounts I can forsee, but once it's done, I won't have to tinker with names anymore.
I'm not happy with this answer, as it creates a really long and ugly formula, essentially repeating the same formula 20 times, but it does work. I feel like there should be an easy function that would be able to do this.
This will return Total sales:
=if(isna(ArrayFormula(QUERY({Lo!$A$5:$F; Tulio!$A$5:$F;Ya!$A$5:$F; Miguel!$A$5:$F;Kevin!$A$5:$F; Octo!$A$5:$F}, "select sum(Col6) where Col1=date '"&TEXT(A28,"yyyy-mm-dd")&"' label sum(Col6) ''",0)))=TRUE,0,ArrayFormula(QUERY({Lo!$A$5:$F; Tulio!$A$5:$F;Ya!$A$5:$F; Miguel!$A$5:$F;Kevin!$A$5:$F; Octo!$A$5:$F}, "select sum(Col6) where Col1=date '"&TEXT(A28,"yyyy-mm-dd")&"' label sum(Col6) ''",0)))
BTW, I get Total sales of $0, $615.50 and $2,498.00
The best way to pull data from a lot of unknown tab names without a script is to actually CREATE the tab names beforehand. On your sheet it looks like you're anticipating/making space for 21 employees. If I were you, I would just create 15 more tabs named Temp7,Temp8,Temp9... etc. Then you can just "hide" those tabs. Then a formula can be built in your totals section that will easily stack all the tabs up using an array literal and a QUERY( { } ) to add up the totals for you without all this INDIRECT() nonsense that you have been going through to pull from the individual tab names.
Would pre-adding tab names be something you were interested in if I could show you the formulas to make the totals easy to calculate?

COUNTIF with IMPORTRANGE with date range and unique ID criteria

I haven't been able to find a solution to get this formula to work after multiple days of searching. The google spreadsheet we use is large and used by many people so I would like to keep this in a separate google sheet using IMPORTRANGE.
Data Needed:
Count of assignments a specific user completed within 7 days and after 7 days based on a start and end date.
Where I'm running into issues:
I simplified the equation by using a small data set in the same sheet to see the main issue. When giving a range for the user # the formula doesn't work anymore. When only comparing it to one user # at a time it does.
For example:
This doesn't work:
=COUNTIFS(C2:C-B2:B,"<7",A2:A,E2)
This one does but needs to have the range for the table to work:
=COUNTIFS(C2:C-B2:B,"<7",A2,E2)
I might be going about this all wrong. Any help I could get is much appreciated.
E2: =UNIQUE(FILTER(A2:A, A2:A<>""))
F2 and drag down: =COUNTIF(ARRAYFORMULA(DAYS(FILTER(C$2:C,$A$2:$A=$E2),FILTER(B$2:B,$A$2:$A=$E2))),"<=7")
G2 and drag down: =COUNTIF(ARRAYFORMULA(DAYS(FILTER(C$2:C,$A$2:$A=$E2),FILTER(B$2:B,$A$2:$A=$E2))),">7")

Resources