Sumifs with or conditional in Google Sheets - google-sheets

I have a database and I need to create a sumifs expression in Google sheets with the following rules: I have a range of cells and this would be a filter for what the sumifs must sum (similar to an OR). I think the image will explain a little bit better what my expected result is:
I have been trying with a lot of examples but none of them have given me the right result.

You can filter the values and then sum up:
First one would be: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$F$4:$F$6))
Second one: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$I$4:$I$5))
You can see an example I uploaded to GDrive

Related

Exclude 0 values from being averaged in Google Sheets

When I try to use the =AVERAGE() function, Google Sheets treats my empty cells as 0. As a consequence, my calculated average value is wrong, see a sample.
Do you have a formula or any advice for this?
I found the formula =IF(EW171=0,"",EW171/EW108), but when I try=IF(EW171:EW180=0,"",EW171/EW108) it does not work.
Usually, Google Sheets automatically ignores empty cells.
If in your case it does not work:
Use =AVERAGEIF() with the criterion ">0".
Sample:
=AVERAGEIF(EW171:EW180,">0")

Google Sheets, Is it possible to use Arrayformula to expand formulas downward when the formula uses arrays

I've been using Arrayformula to auto-expand formulas (such as "=Left(A2:A,B2:B-1") downward, but I need some help understanding this formula. I've read up on the function itself and browsed many forums about this but I can only find articles explaining how to use this with simple formulas, so I'm going to try to as this as simply as possible here: Is it possible to use Arrayformula to expand formulas downward when the formula uses arrays?
The summary for Arrayformula reads "Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays." This was my understanding of how Arrayformula populated a formula into rows automatically. Using this I thought of it as writing a formula that generated an array of formulas, and then splitting them up with Arrayformula. This seems to not work with some formulas such as concatenate, which I will focus my question on. This example is far from my real life problem, but if someone could show me a solution I can apply it elsewhere.
Arrayformula spreadsheet example
Usually when I use Arrayformula with A1:A it would expand the formula through the column, referencing the corresponding rows as it went. With this example I want to have Column C be the concatenated result of columns A and B. Is this possible with Arrayformula? This question is not specific to concatenate, that is just the simplest one that came to mind. Another example would be Countif. Lets say I want to see how many values in the first 5 columns are over 20, and I want that formula to auto populate down, is that possible and if so how would it be done?
Arrayformula second example
P.S. Please don't say copy the formula using the drag handle in the lower right.

How can I use nested formulas in the ARRAYFORMULA function in Google Sheets?

I need Google Sheets to compute sums for each row using the arrayformula() function.
I know I can manualy enter somthing like;
=ARRAYFORMULA(A:A + B:B + C:C)
but I need the use of the functions to do it.
I've tried many things including;
=ARRAYFORMULA(sum(A:A,C:C))
Here is a sample file that I could use help with.
This formula works in cell G3 of your test sheet:
=ArrayFormula(mmult(ARRAYFORMULA(IF(ISBLANK(A3:C),0,A3:C)),sign(transpose(column(A3:C)))))
I've used a custom format to hide the zero values on the empty rows as well
Formulas
Addition (SUM)
QUERY function
=QUERY(A3:C20,"Select A+B+C Label A+B+C ''")
Concatenation
& operator
=ArrayFormula(J3:J20&K3:K20&L3:L20)
CONCAT function
=ArrayFormula(CONCAT(CONCAT(J3:J20,K3:K20),L3:L20))
Explanation
Besides ARRAYFORMULA, Google Sheets has QUERY, FILTER, ARRAY_CONSTRAIN, among other functions that could help you to handle array operations. Take a look to Function List to have the complete list. Also could be very helpful that you to take a look to Using arrays in Google Sheets.

Why does my importrange query fail when I "wrap" with arrayformula

I have the following formula which is currently returning the expected results -
=join(",",query(importrange(vlookup(mid(G4,1,find(",",G4)-1),xref,2,false),vlookup(mid(G4,1,find(",",G4)-1),xref,3,false)),"Select Col3,Col6,Col9 where Col1 = '"&mid(G4,find(",",G4)+1,20)&"' "))
However, I naturally want to make this as dynamic and flexible as possible so I would like to "wrap" it in an arrayformula which ends up like this -
=arrayformula(join(",",query(importrange(vlookup(mid(G4:G,1,find(",",G4:G)-1),xref,2,false),vlookup(mid(G4:G,1,find(",",G4:G)-1),xref,3,false)),"Select Col3,Col6,Col9 where Col1 = '"&mid(G4:G,find(",",G4:G)+1,20)&"' ")))
This formula gives me "Unable to parse query string for Function QUERY parameter 2: NO_COLUMNCol3" error.
I tried to include an iferror to try to trap some error but this made no difference.
I tried various angles to debug and basically focussed on the importrange not providing the data to the query once it was wrapped by the arrayformula. I tried to explicitly reference the external sheet key and range in the importange function, instead of using the lookups, and this did give me a result - but only in the first cell. There should also have been a result returned about 4 rows down.
If I copy the formula down the column, I do get the expected result 4 rows down, but this obviously defeats the purpose of the arrayformula.
In my research in the Google forums there were some suggestions that arrayformula and importrange may not play well together, but no hard and fast facts.
I noticed in this forum that the combination of the two functions has been mentioned but no indication that they did not work together, so I am wondering if there is just some little thing I am missing in my syntax that is causing my ideal scenario not to work ?
I don't think this will work for a couple of reasons.
Firstly, not all the functions in Google Sheets can be automated using an arrayformula, and QUERY is one of them. As far as I know this is because the output of QUERY can be an array itself, so it is not possible to iterate an array output across another array (i.e. your results range).
Secondly, JOIN works across a either a single row or column, whereas your query outputs 3 columns. The arrayformula result would therefore consist of an array with multiple rows and columns, which JOIN cannot use.
I think the best solution is to use the IFERROR as you've described, and copy the single-row formula down the entire column - that way the blank records will not show as errors, but you will be able to add new values to column G and they will be picked up automatically.

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.

Resources