I am working with this function =SUM(IMPORTRANGE("Link", "Sheet!A2:A15")) and it works fine, but now I have issue with cases, where the SUM is not a range but seperate cells, for example:
=SUM(IMPORTRANGE("Link", "Sheet!A2,A8,A15"). How can I fix this?
its either:
=SUM(IMPORTRANGE("Link", "Sheet!A2"),
IMPORTRANGE("Link", "Sheet!A8"),
IMPORTRANGE("Link", "Sheet!A15"))
or:
=SUM(QUERY(TRANSPOSE(IMPORTRANGE("Link", "Sheet!A1:A15")),
"select Col2,Col8,Col15"))
Related
I have a formula that works when it is dragged down but it stops working as soon as it's changed to be an array formula - why could this be?
This is the formula that works when dragged down
=IF(AND($W246:W= "Hired",$Y246:Y<>"Y"),"Workforce Needed","Not")
This is an array formula that suddenly doesn't work. (It no longer pulls back "Workforce Needed" when conditions change - despite me running the same test with the original formula and it working then)
=ARRAYFORMULA(
IF(ISBLANK(F91:F),,IF(AND($W91:W= "Hired",$Y91:Y<>"Y"),"Workforce Needed","Not")))
Column W is a data validation drop down (text)
Column Y is an array formula doing a vlookup
Any ideas much appreciated.
The and() function is an aggregating function and will not get row-by-row results in an array formula. To make it work, use Boolean arithmetic, like this:
(W91:W = "Hired") * (Y91:Y <> "Y")
use:
=ARRAYFORMULA(IF(ISBLANK(F91:F),,IF(($W91:W="Hired")*($Y91:Y<>"Y"),
"Workforce Needed","Not")))
Hi everyone,
I want to get all the rows where A=1, A=2. The query is very simple but I'm not sure why there is no output. I guess is the problem of the format for column A but I'm not sure what should I change in my formula so that the formula can work. Appreciate any help or advice!
A can't be both: 2 and 1. Instead try
=query(A3:C, "Where A = 2 or A = 1", 0)
It should have been OR not AND - it's impossible for any row in a particular column to have two values simultaneously:
=query(A3:C,"select * where A=1 or A=2",0)
QUERY() is good choice. You can also use FILTER() function like-
=FILTER(A3:C,A3:A>=1,A3:A<=2)
I have two sheets in my spreadsheet, I'm trying to get some columns from the first sheet into the second one and clean the data at the same time.
I've tried using:
ARRAYFORMULA(CLEAN({sheet1!A:A, sheet1!E:E}))
{ARRAYFORMULA(CLEAN(android!A:A)), android!E:E}
No error is shown, but the data is not cleaned, what am I doing wrong?
try:
=INDEX({CLEAN(android!A:A), CLEAN(android!E:E)})
or:
=INDEX(REGEXREPLACE({android!A:A, android!E:E}, "\s", ))
It seems that CLEAN formula together with arrayformula can work only with one column or row.
There are two ways to workaround.
First:
You can put these 2 columns one on another and use CLEAN formula and ARRAYFORMULA.
You should use a semicolon between ranges {sheet1!A:A ; sheet1!E:E}
The other method is to use all formulas twice in 2 columns
={ARRAYFORMULA(CLEAN(android!A:A)),ARRAYFORMULA(CLEAN(android!E:E))}
I'd like to run a =SUM(A1:G1), but always skip one column, regardless if it has value or not.
In this case, it should calculate A1+C1+E1+G1.
Is there another function I could append to SUM() or other similar functions as SUM in order to skip one column?
Thank you!
Using the following method you can calculate any number of alternate columns, without the need of manual +
Suppose your data is in second row onwards, use this formula
=SUMPRODUCT(A2:G2, MOD(COLUMN(A2:G2),2))
Simply a sumproduct of cell values and a array of {1,0,1,0,1...}
Another slight variation
=SUMPRODUCT(A2:G2*ISODD(COLUMN(A2:G2)))
But if the even columns contain letters instead of numbers this will give an error, so you can use instead
=SUMPRODUCT(N(+A1:G1)*ISODD(COLUMN(A1:G1)))
Comparing #AnilGoyal's answer, this works as well
=SUMPRODUCT(A1:G1,--ISODD(COLUMN(A1:G1)))
You can use:
=SUM(INDEX(A1:G1,N(IF(1,{1,3,5,7}))))
Or with Excel O365:
=SUM(INDEX(A1:G1,{1,3,5,7}))
A bit more of a general solution:
=SUMPRODUCT(MOD(COLUMN(A1:G1),2)*A1:G1)
Or with Excel O365:
=SUM(MOD(COLUMN(A1:G1),2)*A1:G1)
Or even:
=SUM(INDEX(1:1,SEQUENCE(4,,1,2)))
Since you included Google-Sheets, I'll throw in an option using QUERY():
=SUM(QUERY(TRANSPOSE(1:1),"Select * skipping 2"))
Maybe a bit more verbose, but very understandable IMO.
Consider something of the format:
=SUM(A1:G1)-INDEX(A1:G1,2)
The 2 in the formula means remove the 2nd item in the part of the row. (so the 999 is dropped)
So the formula =SUM(BZ10:ZZ10)-INDEX(BZ10:ZZ10,2) drops CA10 from the sum, etc.(a similar formula can be constructed for columns)
google sheets:
=INDEX(MMULT(N(A1:H3), 1*ISODD(SEQUENCE(COLUMNS(A:H)))))
=INDEX(IF(ISODD(COLUMN(A:H)), TRANSPOSE(MMULT(TRANSPOSE(
IFERROR(A1:H3*ISODD(COLUMN(A:H)), 0)), 1^ROW(A1:A3))), ))
Trying to break apart rows containing numbers like "198,183,158,315,274" by their comma, and then average them out and divide them by a singular number; using arrayformula. It only produces one row of result and it's incorrect though?
Here is my test sheet, editable
Thanks for any help.
try:
=ARRAYFORMULA({"Average"; IF(A4:A="",,
IFNA((MMULT(1*IFERROR(SPLIT(INDIRECT("A4:A"&
MAX(IF(A4:A="",,ROW(A4:A)))), ",")),
ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(A4:A, ","))))^0)/
(1+LEN(REGEXREPLACE(A4:A&"", "[0-9\. ]", ))))/B1))})
spreadsheet demo
Another solution:
=ArrayFormula({"Average";(ArrayFormula(mmult(N(array_constrain(ArrayFormula(IFERROR(SPLIT(A4:A8,","))),MATCH(2,1/(A4:A8<>""),1),5)),sequence(Columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)/mmult(N(array_constrain(if(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))>0,1,0),MATCH(2,1/(A4:A8<>""),1),5)),sequence(columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)))/$B$1})