ArrayFormula and sum total [duplicate] - google-sheets

This question already has answers here:
Arrayformula sum one column until this row
(2 answers)
Closed 5 years ago.
I'm trying to print in column B the sum of all the previous rows of column A. Through the usual formulas this is done like this:
B1: = A1
B2: = A2 + B1
B3: = A3 + B2
B4: = A4 + B3
But I need to do this using arrayformula. I tried in A1 to enter this: =ARRAYFORMULA(IF(A1:A4<>"";SUM(INDIRECT("A1:A"&ROW(A1:A4)))))
(If I'm not mistaken, in the English version, instead of ";" is used ",")
But it does not work:
Tell me, please, how can I solve this problem using arrayformula?

Based on #TomSharpe's answer a while back:
=ARRAYFORMULA(SUMIF(ROW(A1:A4), "<="&ROW(A1:A4), A1:A4))

Related

Array of IMPORTRANGEs in Google Sheets

For this sample table:
A
B
C
D
E
1
Range!A1:C5
URL1
= Formula here
2
URL2
3
URL3
4
...
I have this working formula in C1:
={IMPORTRANGE(B1, A1); IMPORTRANGE(B2, A1); IMPORTRANGE(B3, A1)}
A1 contains the range to pull from the target Sheets.
Links to the target Sheets are found in column B.
(This is a simplified example. My actual Sheet has 21 entries in column B.)
Question:
If I will have to add/remove URLs in column B, I have to adjust the formula in C1 and add/remove IMPORTRANGEs.
I would like to have a formula that automatically adjusts to the entries in column B.
Solutions tried:
I tried this, but it did not work:
={JOIN("", ARRAYFORMULA(IF(LEN(B1:B), "IMPORTRANGE(""" & B1:B & """, """ & A1 & """); ", "")))}
The JOIN function returns a text that should be identical to what the array { ... } parses as a formula. But it doesn't. Wrapping it with INDIRECT also does not work.
Any suggestions on how I could make this work?
if by "working formula" you mean valid formula that returns data then only thing you can do is hardcode it like this:
=QUERY({
IFERROR(IMPORTRANGE(B1, A1), {"","",""});
IFERROR(IMPORTRANGE(B2, A1), {"","",""});
IFERROR(IMPORTRANGE(B3, A1), {"","",""})},
"where Col1 is not null", )
A1:C5 = 3 columns = {"","",""}
you can generate formula dynamically with arrayformula but the result will be always a text string and not active formula. tho if you wanna go this way you will need a script that will convert your text string into active formula. example:
https://stackoverflow.com/a/73119313/5632629
https://stackoverflow.com/a/61819704/5632629

Google Sheets: Perform a running formula in the same column

I have a simple formula I want to perform in the same column.
Link to sheet
Column A: dates
Column C: multiplier
Column B: where I want to perform the formula.
B2 = B1-B1*$C$1
B3 = B2-B2*$C$1 etc
I'd like to automatically run the formula as the number of months (in Col A) changes.
​A
B
C
1/4/22
100
0.5
1/5/22
50
1/6/22
25
try:
=ARRAYFORMULA(IF(A2:A="",,B1*C1^SEQUENCE(COUNTA(A2:A))))
=arrayformula( B1 * (1 - C1) ^ sequence(count(A2:A)) )

Reference to the cell which contains a certain date [duplicate]

This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 3 years ago.
I have a problem with the query function in Google Sheets.
=QUERY(A1:D7; "Select B where C contains '"& F1 &"' ";0)
These formula works if the cell F1 contains a text or a number. But if it contains a date it turns with a N/A mistake.
As a result I need to get the data from the column B which is placed in the line with the certain date.
Please, could you help me? What do I do wrong?
for a date do:
=QUERY(A1:D7; "select B where A = date '"&TEXT(F1; "yyyy-mm-dd")&"'"; 0)
or do:
=ARRAYFORMULA(QUERY(TO_TEXT(A1:D7); "select Col2 where Col1 = '"&F1&"'"; 0))

How to properly reference cells to avoid REF error when modify them

I have this spreadsheet:
https://docs.google.com/spreadsheets/d/1nQzpJ1cOT8kdo-b_vFFoSIHyLMhqd__Cv4SipncVTnA/edit?usp=sharing
In Sheet 2:
A B C D
col1 col2 col3 col4
1 2 3 4
2 4 6 8
1 3 5 7
Then I want to copy all these numbers in Sheet1, so in Sheet 1 I have this formula in the cell A3:
A3: =IFERROR(INDIRECT("'"&B2&"'!A2:O"),"")
Where in B2 of Sheet1 I have the string "Sheet2".
Everything works fine. However, If I try to modify one of the cells which is referenced in Sheet1 (for example B3) I get
#REF error
Why is this and How can I avoid it?
it's because the range you selected to import from other sheet is A2:O which includes empty cells. to resolve it you can use dynamic ARRAY_CONSTRAIN and skip the empty cells with COUNTA like:
=ARRAY_CONSTRAIN(IFERROR(INDIRECT("'"&B2&"'!A2:O"), ),
COUNTA(Sheet2!A2:A), COUNTA(Sheet2!A2:2))
to modify B3 on Sheet1 you will need to go in Sheet2 and modify it there because those data are only "visually" imported from another sheet. eg. when you modify cell B3 then cell B3 is no longer empty and the stuff you want to import has no space to be enrolled (it can be enrolled only on empty cells)

Assistance with returning value based on cell being populated with number

Hello and thank you for looking at my post. I am a super noob at spreadsheets but need to automate part of a cost spreadsheet in open office calc after my assistant has repeatedly managed to forget to enter the right data. Here we go:
PART 1
Output is in cell D1.
I have a column of cells A1 to A10, if there is a number (any number) in one or more cells from A1 to A3 then I need the D1 to equal cell B1
+ 1.
If there is also a number in A4 to A6 then this supercedes the previous formula and D1 will now be B1 + 2.
Lastly if there is a number in A7 to A10 then again all previous code is superceded and D1 is now B1 + 3.
PART 2
I have cells C1 to C3. If D1 equals B1 + 1, C1 will equal D1 if greater than 3, else it will be 3. C2 and C3 must be 0 or empty.
If D1 equals B1 + 2, C2 will equal D1 if greater than 4, else it will be 4. C1 and C3 must also be 0 or empty.
If D1 equals B1 + 3, C3 will equal D1 if greater than 5, else it will be 5. C1 and C2 must also be 0 or empty.
To me this seems almost impossible, I've spent all day trying to learn IF and ELSE statements and ISNUMBER and many other approaches and I've run out of options. Any help or advice would be greatly appreciated and if I haven't been clear please ask me to clarify any point.
Find a column where you can put some other formulas, for example column E. Breaking the formula into parts will make it easier.
In E1, put =IF(E4, 3, IF(E3, 2, IF(E2, 1, 0))).
In E2, put =OR(ISNUMBER(A1),ISNUMBER(A2), ISNUMBER(A3)).
In E3, put =OR(ISNUMBER(A4),ISNUMBER(A5), ISNUMBER(A6)).
In E4, put =OR(ISNUMBER(A7),ISNUMBER(A8), ISNUMBER(A9), ISNUMBER(A10)).
Then the formula for D1 will be simply =B1 + E1. This is part 1 in the question.
For part 2, the requirement of "C2 and C3 must be 0 or empty" should not be needed, because they will be empty if D1 equals B1 + 1 anyway. So this is all that is needed:
In C1, put =IF(E1=1, IF(D1>3, D1, 3), "").
In C2, put =IF(E1=2, IF(D1>4, D1, 4), "").
In C3, put =IF(E1=3, IF(D1>5, D1, 5), "").

Resources