I am using a google sheet as a database. When a row is populated (using JSON API and Integromat), I want formulas in the newly added row to update. However, I cannot get the formula to be applied to the whole column automatically.
For instance, C1 is =A1+B1. When A2 and B2 are added, C2 should be =A2+B2.
I have tried:
Double clicking the box in the bottom right corner of the selected cell. This does not work because it adds the formula for all rows that contain data. When a new row is added, the formula is not applied to that row.
Using the formula with a range =A1:A+B1:B. This formula is only applied to the selected cell.
Pasting the formula in the column header. This simply did not work. Even when I tried to include a formula that used a range =A1:A+B1:B.
Using hotkeys like shift + ctrl + Down + D. I was unable to find any that worked. Most were for windows computers (I am using a mac).
I'm sure I'm just making a stupid error, but I haven't been able to find any solutions.
Thanks in advance!
Place this in the header row (assuming the header row and you want to add all other rows).
={"YOUR HEADER";ARRAYFORMULA(A2:A+B2:B)}
Related
I want the sum of values in a column. However I wish to ignore cells which do not contain a formula. I tried
=SUMIF(A1:A10, ISFORMULA(A1:A10))
But that did not work
if its a small range you can do:
=SUM(FILTER(A1:A10, {ISFORMULA(A1); ISFORMULA(A2); ISFORMULA(A3);
ISFORMULA(A4); ISFORMULA(A5); ISFORMULA(A6);
ISFORMULA(A7); ISFORMULA(A8); ISFORMULA(A9); ISFORMULA(A10)})
This way might work for you.
I added a column with the following formula, which unfortunately also doesn't work as an arrayformula. But if you put this at the top of your column, beside the one you want to sum, and double click the "drag down" blue square on the bottom right corner of the cell, it will fill all the way down, provided you have no blank rows. Dragging down also works obviously.
=IFNA(FORMULATEXT(A1),0)
This creates a column of zeroes and text formulas, which you can use as a filter for your SUMIF formula, as follows: (assumes data column is A1:A30, helper column is B1:B30. SUMIF is in C1)
=SUMIF(B1:B30,"=0",A1:A30)
Let me know if this is useful, or not.
I have a value in G3 and a value in H3. In I3 I have the following formula:
=ARRAYFORMULA(G2:G&"."&H2:H)
(Note that the formula and the problem below is in multiple rows below)
to show the values in G3 and H3 together as a decimalised value. I used the array formula as I needed a way to insert new rows and maintain the formula in the I column as I want new information to be at the top. All was working fine but I've entered the spreadsheet this morning to find the correct values in the I column but without the formula there (except in row 2 which is blank and used as a divider between headers and info).
Any ideas as to why this has happened, please?
Example sheet: https://docs.google.com/spreadsheets/d/14ma-y3esh1S_EkzHpFBvLb0GzDZZiDsSVXFktH3Rr_E/edit?usp=sharing
In column B of ItemData sheet, I have achieved the result I want by copying the formula into every cell in the column, but I want to solve this using ArrayFormula instead.
In column C I have achieved the same result using ArrayFormula. However, for addition, column C is referring to cells in column B, while column B is referring to cells in column B. I.e. every cell in column B is adding 1 to the cell on the row above.
If I select the C3 formula text and paste it into the cell edit field for cell B3 (to not screw up cell references during copy - I know I could make them static references, but this is not my problem), the cell gets an error value of
#REF!
Error
Circular dependency detected. To resolve with iterative calculation, see File > Spreadsheet Settings.
Do note that the additions that need to be done are the same in both cases: Add 1 to the value of the cell on the previous row, so there is no circular reference involved. There is a starting value provided in B2, and cells in B3 and downwards should use the data from the B cell in the previous row.
Also, note that I did try File->Spreadsheet settings and enabling circular reference computation with max 25 items, but this only fills in the first two cells (B3 and B4).
How can I solve this problem? I would prefer having something like ArrayFormula, where the formula only exists in a single cell. But copy-pasting would be acceptable as long as any new rows, inserted in between or added at the bottom, would get the same formula added in column B.
Will matching items always be consecutive? It seems that way since you're comparing each Item cell to the cell above it right in your formula logic. That breaks an [unwritten?] rule of spreadsheet normalization; values' addresses themselves generally should not be treated as data.
IF you're committed to it though, have you considered explicitly using location as a data source? Example:
=ARRAYFORMULA(IFS(
NOT(LEN(A3:A40)),,
ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0)<=VLOOKUP(VLOOKUP(A3:A40,Items!$A$2:$D,2,false),DataPerColor!$A$2:$B,2,false),ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0),
true,
))
Just like your formulas, all that does in English is:
for each row,
if there's no Item, don't output any ItemData,
if the number that belongs in this cell¹ is less than or equal to the lookup, print it,
otherwise, don't output any ItemData
But then what is ¹ "the number that belongs in this cell" and how can we calculate it without using column B? I abuse locations of things to get it. Looking down your row B, each number that appears is just:
this row's number, minus
the row where items start [always 3], minus
the row number [in just the Item rows] of the first row containing this row's Item
Using the second-to-last ItemC as an example: the first ItemC is the 16th item listing, and the one we're looking up… the "second-to-last ItemC" is in row 21 of the sheet. 21-3-16 = 2 …the number you wanted.
If you can stomach that, it's a single formula and does work according to your specifications.
I've searched for hours and couldn't find an answer to the following problem:
I have two sheets, Blue and Red.
I want Blue!A1 to be "exactly" like Red!A1 but I find this problem:
Red!A1 contains "B1+B2", both are Red's cells.
However, when I write Blue!A1 like this: "=Red!A1", the return value is something like "=Red!B1 + Red!B2", and not the "=CurrentSheet!B1 + CurrentSheet!B2"
My problem is that I cannot reference the Blue sheet in the Red one because I want dozens of sheets referencing Red in the same way, so when I change A1 in Red I change all the other sheets' A1 accordingly with their respectives B1s and B2s, not Red's B1 and B2.
I want to have a cell in a sheet which can be referenced by any other cell in any other sheet exactly like it was in the first place.
For instance, if I have a cell which contains =B1+B2 in a sheet, I want to reference it in another sheet in a way that the new =B1+B2 references the current sheet's B1 and B2 cells instead of the former one's.
Can someone help me to solve this problem?
Thank you in advance
Alexandre Trajano
Solution 1
Copy & Paste.
In Google Sheets, copy & paste iterates the formula automatically. If you change sheet, it will change the referenced cells to point to the current sheet; if you change location within the same sheet, it will shift the cell references according to how many columns and rows you shifted.
In contrast, cut & paste will move the formula without iterating the cell references.
Solution 2
If you have a truly large number of sheets you want to create based on a template and don't want to c&p a thousand times, you can use Apps Script.
In particular, you will need
Spreadsheet App to create and access new sheets; and
Functions that manipulate cells here.
You can enter the formula via Apps Script as strings.
For example, say you want cell A1 to have formula B1+C1 in a tab named "Sheet1". You can do the following.
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var tab = sheet.getSheetByName('Sheet1');
sheet.setActiveSheet(tab);
var cell = tab.getRange(1, 1); // The arguments are the row and column indices of A1, respectively.
cell.setValue('=B1+C1');
There are many things you can do here with the basic template. You can generate sheets based on some naming convention. You can generate formula based on the cell position. You can create a script that fills in the formula upon the creation of a tab if its name observes a certain rule. etc etc. And naturally, you can duplicate the formulas from one sheet. You will need getFormula() as opposed to getValue.
Note: you can also call
custom Apps Script function directly in your sheet and write your cells using the output of your custom function. But in your case, using the range functions in Apps Script should be more efficient.
I have an IMPORTRANGE formula in Google Sheets and want to apply it in the rest of the cells below. When I drag down the formula, it stays the same:
=importrange("1jhXCPi6RUf8MD7XoYgQsH-E0x768UtVxE3XY_kBrbkE","OCT!F2")
How can I drag a formula and have it automatically increment the value (OCT!F2 should be change into OCT!F3 up to OCT!F118)?
When I drag down this formula, I want it to be like this.
=importrange("1jhXCPi6RUf8MD7XoYgQsH-E0x768UtVxE3XY_kBrbkE","OCT!F3")
You may use row formula:
"OCT!F3" = "OCT!F" & row(A3)
You may also include the range in single importrange:
"OCT!F2:F500"
Be careful: importrange formulas may slow down your sheets.