Sum of referenced ranges in google spreadsheets - google-sheets

In Google spreadsheets, how do I find the sum of two ranges referenced from different spreadsheets
I want to use something like
=(IMPORTRANGE("keyofsheet1","A1:A100")+ IMPORTRANGE("keyofsheet2","A1:A100"))
and get the sum
Apparently, the above doesn't work. Any help would be appreciated :).

I have found an answer:
Arrayformula is what I was looking for. It basically applies the formula treating the range as a range, instead of as a single element. I still donot totally understand why this works. would be really happy if someone could explain this
I just used
ARRAYFORMULA((IMPORTRANGE("keyofsheet1","A1:A100")+IMPORTRANGE("keyofsheet2","A1:A100")))
and suddenly everything works as it should.
Shouldn't the + operator be conscious of the input type it is getting and automatically respond by returning the appropriate type? why do I need to explicitly specify that this is an array formula

I ran into a similar issue yesterday. Solution was:
=SUM(IMPORTRANGE("keyofsheet1","SheetName!A1:A100")) + SUM(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"))
No need to use ARRAYFORMULA()
2 important notes.
You will probably see a #REF! error in your cell with a red color in the corner. You'll need to hover over it and allow access to the spreadsheets that you're referencing.
If any of the original data in the spreadsheet ranges you're referencing in A1:A100 contain errors such as
#NULL!
#DIV/0!
#VALUE!
#REF!
#NAME?
#NUM!
#N/A
then your formula must be modified to include SUMIF() as follows
=SUMIF(IMPORTRANGE("keyofsheet1","SheetName!A1:A100"), ">0") + SUMIF(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"), ">0")
This ensures that it's only adding anumbers and not error codes.

Related

Xlookup issue with Indirect function in Google Sheets

I am utilizing a xlookup with indirect references function with certain date ranges to determine the range of rows to search in. With 3k rows of data and repeating values this helped me pair down to non-repeating values so I don't have an errant value from an earlier entry. The xlookup initially worked great when I manually inputted range of rows to search in but when indirect was introduced I am getting my error message I programmed (leading me to believe there isn't an error with my function)
When I utilize the direct references (meaning I'd have to change the date ranges directly in formula) it works great!
`=xlookup(T3,Statistics!F203:F215,Statistics!A203:215,"Not Scheduled",1,1)`
However when I use indirect to reference the specific range (so that I can adjust the date range over one cell and the reference rows recalculate) I get the error message I programmed.
`=xlookup(T3,indirect(Statistics!Q11&":"&Statistics!R11),indirect(Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)`
Q11=F203
R11=F215
T11=A203
U11=A215
The correct answer lies in Row F205 which is within the ranges specified in the function.
Usually I figure these out or find a typo when utilizing my functions but I'll be honest and say this has me stumped. The references on the other page are identical. Just for note I also tried a Concateate function to combine the two cells before calling indirect with the same result. Any help would be greatly appreciated as this would add verification to a transportation system instead of double entry across two systems.
As far as I see it, what I think you're missing is the name of the sheet. You're referencing to the cells but not clarifying that the INDIRECT function has to look into "Statistics". Try adding it:
=xlookup(T3,indirect("Statistics!"&Statistics!Q11&":"&Statistics!R11),indirect("Statistics!"&Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)
About that 1 after "Not Scheduled", are you sure you don't want an exact match only? Meaning to use a 0 instead of 1

Google Sheet SUMIF returning an error! statement

pretty new to google sheets, my question could seems awkward but i'm struggling with a sumif in google sheets.
I'm using a sumif to sum up some values with a simple condition and i struggle to find the right way to do it. Assuming the documentation i do it well but i must be missing something because the result is always : ERROR!
See the example below
The example is simple, applying exactly what the documentation says but still not working.
I tried to make the cell format number for the condition, still not working.
I tried to make the condition a string by typing "=1", still not work. I tried to use a cell value in the condition B5 for example, still not working.. I'm desperate, i don't understand why this simple example is still not working.
If someone could help it will save my time.
Chances are that your spreadsheet is using a locale that expects formula arguments to be separated with semicolons instead of commas, like this:
=sumif(B5:B10; 1; C5:C10)
You can set the locale in File > Settings > Locale.

Is there a way to use ARRAYFORMULA to find the most-recent even input of a column?

SOLVED EDIT
Thank you for the help. Solution here.
ORIGINAL POST
I have made a google sheet to describe the issue I am facing linked here (https://docs.google.com/spreadsheets/d/1yK6ZAX8BFnEqiuQO9HIxuY0l62ewDDccj-8EN1r2i2w/edit?usp=sharing).
I will also describe in words, below, the problem I am facing, along with the solutions I have tried.
The data of column A are random single-digit (0-9). I would like column B to show the most recent even number from column A, but only up to a specific row. That specific row is the row corresponding to the row of the cell in column B. In other words, in cell B7, I want to find the most recently entered even number of column A, specifically only on the range A2:A7 (A1 contains a column header).
This is actually a pretty simple formula, and I can get the desired outputs by simply checking if the value in a cell in column A is even and then returning the value of that cell if it is, or the output of the cell above if it isn't. So the formula would look something like: ​=IF(ISEVEN(A7),A7,B6)​
However, my problem is that the length of the data in column A will be growing as more data are entered, and my current solution of using the fill handle to copy the formula to new cells is inelegant and time-consuming. So my desired solution is to use an array formula entered into the first cell of column B (B2), capable of returning the same value as the other formula. The formula I tried to enter to perform this was the following: ​=ARRAYFORMULA(IF(ISEVEN(A2:A),A2:A,INDIRECT(ADDRESS(ROW(A2:A)-1,2))))​
However, as some of my previous work with arrays has taught me, not all formulas iterate as expected down the array. The formula seems to be able to return the correct output on lines which are already even, but it is unable to return the expected most-recently entered even number for all the other lines. It appears that the formula is not able to appropriately interpret the ​value_if_false​ argument of the ​IF​ formula.
I'm a little new to scripting, so I'm still trying to learn, but I also tried to dabble around with custom functions to no avail. I'm still wet behind the ears when it comes to coding, which is why I've been so lenient on the built-in formulas of Google Sheets, but I fear I may have reached the limit of what Sheets formulas can do.
I am open to trying new approaches, but my only real constraint is that I would really like for this to be a one-touch (or even better no-touch) solution, hope that's not too far beyond the scope of this issue. Any assistance would be much appreciated.
EDIT
After rubber-ducking the problem here, I went back and tried to use the OFFSET formula, hoping I could get it to play nicely with the array formula. Alas, I was unable, but I thought I should at least post my progress here for reference.
Attempt with offset
Still working at it!
Doing a vlookup on the row number seems to work for me
=ArrayFormula(if(A2:A="","",vlookup(row(A2:A),{if(iseven(A2:A),row(A2:A)),A2:A},2)))
Note: if there are no even numbers in range for some rows, it will produce #N/A for those rows.

SUMIF with FIND as criteria

I'm trying to summarize data from several Google spreadsheet' sheets in a single one but I have some issues with SUMIF and FIND.
To Sum data from another sheet I have to use this (at least that's the only solution I've found)
=SUM(INDIRECT(""&A6&""&"!E2:E"))
Where I have the name of my sheet on A6.This makes everything easy because I have a column (A) with all the names of the sheets. I haven't found something like Sheets[1] in Google Docs.
My next step was to Sum Times from a specific column but remove a specific values, which in this case is 1 that get transformed internally 24:00:00 since it's a time column:
=SUM(INDIRECT(""&A6&""&"!D2:D")) - SUMIF(INDIRECT(""&A6&""&"!D2:D");"24:00:00")
Here I tried to do everything with a single SUMIF but I have no idea how. NOT("24:00:00") didn't work so I settled to this.
The last part is the most difficult and I'm not able to solve it.
I have a column with month names (for example) and I want to sum some data only when the month name contains "er". Here is what I thought:
=SUMIF(A6:A16,ISNUMBER(Find("er")),G6:G16)
This gives me always 0
(Note that the last one contains A6:A16 instead of the whole INDIRECT part because I am still testing it in a single sheet.)
Any Idea what I'm doing wrong?
I don't know why the above SUMIF doesn't work, what I've tested and works is:
=SUMIF(A6:A16,"*er*",G6:G16)
SUMIF is NOT SUM + IF as I thought. I hope it will help someone else.

Google Spreadsheet range names

In Google Docs Spreadsheets, one can use Range Names to put labels on ranges of cells to make formulas more legible. In most formulas, one can use the range C:C to denote the entire C column, and C2:C to denote the entire C column after and including C2.
Is there a way to create range names of the same nature? When I try C:C or C2:C or Sheet!C:C or 'Sheet'!C:C I always get the error "The range you specified is not in a valid range format." I would like the range name to expand as my form adds rows to my spreadsheet. Thanks.
I just discovered the if you use the '-' operator, it starts from the bottom row. So,
=INDIRECT("-D:D12")
starts from the last row and works it's way up to D12!
I had a similar problem. Although I do not know how to do exactly what you are asking, you can do essentially the same thing by referencing cells that are not yet created.
For example:
Column C currently has 100 cells (100 rows in the sheet)
Instead of referencing it with C:C, use C1:C999
If you make the row reference high enough, then you can account for future rows that you will create. Hope it helps.
I don't think so... even if you select a column manually while in the Range Name selector, it complains. That would be a nice feature and it would make sense since they support column ranges for formulas already.
I believe this does work now. I have a range name of "Sheet1!A10:AW10" with no problems.
If you try to do a whole column, I think it will just take all the available cells in the column at that time. i.e. if you make more cells later, you need to manually add to the range name.
I had the same problem with ranges such as A3:A which normally work in other places such as ARRAYFORMULA(), but the workaround is to not specify the starting row, such as A:A. In cases when this would be a problem, you can proxy the data through another column using something like ARRAYFORUMULA(A25:A) as the formula.
Update: Apparently I haven't read the question properly. I see that the OP had tried leaving out the row number, so perhaps it wasn't working at that time, but it does now. The notations still don't work.
Update2: I didn't notice that google spreadsheet replaces ranges like A:A to A1:A50, so new rows added later on do not still get included. That I think is what #Dean is trying to say in his answer.
I think it's a helpful tool to use Insert -> Define new range to make a wizard appear and make the syntax correct. Hehe
My response in other topic

Resources