How to convert SUMIFS to Array Formula Google Sheets - google-sheets

I have been trying to Convert the SUMIFS formula into Array but its not working in google sheets then i tried to follow online instructions and i am unable to that.
I hope someone can help me to fix the fomrula:
Formula1:
SUMIFS('Employee Leave Setup'!$I:$I,'Employee Leave Setup'!$B:$B,$B2:B,'Employee Leave Setup'!$X:$X,K$1)
Formula2:
=ArrayFormula(if(len(B2:B), iferror(vlookup(B2:B,QUERY({'Employee Leave Setup'!B:X}, "SELECT Col1, COUNT(Col22) Group by Col1 label COUNT(Col22)"",0),2,),0),))")))))
Sheet

Try:
=MAKEARRAY(COUNTA(B2:B),COUNTA(K1:W1),LAMBDA(r,c,SUMIFS('Employee Leave Setup'!I:I,'Employee Leave Setup'!B:B,INDEX(B2:B,r),'Employee Leave Setup'!X:X,INDEX(K1:W1,,c))))

You can also use SUMIF and concatenate the conditions.
=ArrayFormula(IFERROR(1/SUMIF('Employee Leave Setup'!B5:B&'Employee Leave Setup'!X5:X,B2:B&K1:W1,'Employee Leave Setup'!I5:I)^-1))

Related

How can I query from multiple Google sheets?

I wanted to query data from multiple sheets but couldn't find the correct formula. I used the below formula and it worked fine with querying from one sheet.
=QUERY('2022'!A1:S38, "Select B,H where R='N' and S=TRUE order by H")
Then I used the below formula hoping that I could derive the information from 2 sheets but it didn't work. Appreciate if someone could help me on this
=QUERY({'2022'!A1:S38;'2023'!A1:S38}, "Select B,H where R='N' and S=TRUE order by H")
use Col references:
=QUERY({'2022'!A1:S38; '2023'!A1:S38},
"select Col2,Col8
where Col18='N'
and Col19=TRUE
order by Col8")

Textjoin or Concatenate for this case?

hope you have a good day/evening.
Due to I always seems to use importrange function to import multiple sheets. I want to have a quicker way to replace the date (highlighted in red as per the screenshot) with the date referenced in Col A. This is my Google Sheet under the tab name "TextJoin" Google Sheets Link
try:
=INDEX({""; "={"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}"})
but you may need to wrap it into query and remove empty rows perhaps like:
=INDEX({""; "=QUERY({"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}, ""where Col1 is not null"", )"})
Try
=importrange("_____","'" & text(A2,"M/d/yy") &"'!A2:C")

Using Countif, Vlookup and Importrange

I'm currently struggling with using the Countif, Vlookup and Importrage formula on Google Sheets...
I need to pull data from the raw data sheet to the data set that I'm using and can't get it right.
Formula that I have is as follows:
=countif(vlookup(A2,IMPORTRANGE("URL","Data!A2:I940"),9,false),"supplier")
I need to look up the date and then get the count for how many "Suppliers" we had on that specific dates..
Anyone having the same issue or is my brain just over worked???
I think a better choice would be to use a query formula instead.
Please follow the logic of this given formula
=QUERY({B1:D12},"select count(Col1)
where Col3=date'"&TEXT(F1,"yyyy-mm-dd")&"' and Col2='"&F2&"'
label count(Col1) '' ")
(Do adjust ranges to your needs)

How to import some Infinitely Repeating Offset-Cells from an ImportRanged WorkSheet? (Google Sheets)

I'm trying to import some specific cells from one worksheet to another, and I want to do so in a repeating, intermittent way.
For instance, if A51 is the first cell to be imported, I want to import A51 and all "reoccuring next fifth cells" in the same row (A56, then A61, then A66 and so on).
I figured I'd only need to use ArrayFormula, ImportRange and Offset, but I couldn't be more wrong. In my inexperienced mind, the formula would look something like this:
=ARRAYFORMULA(OFFSET(IMPORTRANGE("url";"Page1!A51:51");0;5))
... but it obviously doesn't work. I keep falling into the same problem no matter how much I tweek it, "the argument must be an interval". I've stumbled across similar problems here in StackOverflow, but none of them were quite the same issue; I tried their solutions and they also didn't work.
e.g. Exemple
So now I resort to you, great SO community. Could anyone explain to me why am I failing so miserably in a (most probably) simple task? I appreciate any help!
Thanks!
First see if you can just omit blank values and get the result you want. In the Input spreadsheet, choose Insert > New sheet and put this formula in cell E4 of the new sheet:
=query( transpose('Página1'!B4:4); "where Col1 is not null"; 0 )
You can then do the same in the Output spreadsheet with these formulas:
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "Página1!B4:4")); "where Col1 is not null"; 0 )
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "Página1!B6:6")); "where Col1 is not null"; 0 )
If that is not what you needed, please show more realistic-looking sample data in the Input spreadsheet and the hand-entered results you would like to get from that data in the Output sheet. Do not show ColB;Row4 but the actual results you would like to get.

Is there a way to make a query with an importrange to mimic a sumif formula from another Google sheet?

I am encountering a capacity issue with one of my spreadsheets but certain information in the sheet still needs to be available to cross-reference. The original spreadsheet contains this formula:
=sumif(A:A,A2,N:N)=O2
I tried to do a direct transfer to the new spreadsheet by adding importranges like this:
=SUMIF(IMPORTRANGE("URL","Sheet1!A2:A"),IMPORTRANGE("URL","Sheet1!A2"),IMPORTRANGE("URL","Sheet1!N2:N")=IMPORTRANGE("URL","Sheet1!O2")
The equation keeps putting out an error saying "argument must be a range". Then I tried to write it out as a query like this:
=QUERY(AND(IMPORTRANGE("URL","Sheet1!A:A"),IMPORTRANGE("URL","Sheet1!N:N"),"SELECT SUM(CASE WHEN Col1=A2 THEN Col14)=O2"))
But the equation is showing FALSE as the result when it should say TRUE. I have attached an example spreadsheet so that these equations make more sense.
I also need the equation to take into account any new information that is placed on the new spreadsheet while also comparing it with the old info. I tried doing this to start with but then slowly realized the initial equation itself doesn't work.
=SUMIF(IMPORTRANGE("URL","Sheet1!A2:A"),IMPORTRANGE("URL","Sheet1!A2"),IMPORTRANGE("URL","Sheet1!N2:N"))=IMPORTRANGE("URL","Sheet1!O2")+SUMIF(A:A,A2,N:N)=O2
Any help is appreciated.
https://docs.google.com/spreadsheets/d/1q1cWh58p23dcQulQ4rz6v4iiDywEFHvcrvASao61xxo/edit#gid=0
use this formula instead of SUMIF:
=ARRAYFORMULA(IF(LEN(
IMPORTRANGE("1q1cWh58p23dcQulQ4rz6v4iiDywEFHvcrvASao61xxo","Sheet1!C2:C")),
IF(IFERROR(VLOOKUP(
IMPORTRANGE("1q1cWh58p23dcQulQ4rz6v4iiDywEFHvcrvASao61xxo","Sheet1!C2:C"),
QUERY(IMPORTRANGE("1q1cWh58p23dcQulQ4rz6v4iiDywEFHvcrvASao61xxo","Sheet1!A2:N"),
"select Col3,sum(Col14) where Col1 is not null group by Col3 label sum(Col14)''"),2,0))=
IMPORTRANGE("1q1cWh58p23dcQulQ4rz6v4iiDywEFHvcrvASao61xxo","Sheet1!O2:O"), TRUE, FALSE),))

Resources