I know how sumif works when I need to access it within the same Google "workbook" (using the analogy from excel). By workbook I mean a collection of sheets, not sure whether there is a different way to refer to Google workbook.
For example in the sheet (Example 3): https://docs.google.com/spreadsheets/d/1Dm-N-1X38zHartE3JbPUtWDnYwEpkGHl6v06huvjSa8/edit#gid=0
I have Sheet2, with column A contain strings and column B containing numerical value. On sheet 1, I have a sumif function which can be query data stored in Sheet2, and sum the cells which match A1 in Sheet1.
The problem starts happening when I try to refer to ranges in a completely different workbook, which is shown below.
I am trying to do a sumif over 2 ranges from a different "workbook". The data is stored here (Example 2): https://docs.google.com/spreadsheets/d/1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0/edit#gid=0
The Sumif function is in Cell B1 of the following sheet (Example 1):https://docs.google.com/spreadsheets/d/1AitilELd6w7Dbv9d-mKhBYGTBaO6DdkU29Y5mofX2TI/edit#gid=0.
From my understanding importrange is typically used to refer to ranges in completely different workbooks, as a result I use importrange as the first and last arguments in the sumif function in the Sheet Example 1.
What am I doing wrong? Why is this not working?
Can anybody help?
Thanks a lot
See if this query does what you want:
=SUM(query( QUERY( Importrange("1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0","Sheet1!A1:B10") ) , "select Col2 where Col1 contains '"&A1&"'" ) )
Related
Hey Stack Overflow Sheets, I have a question regarding a use case we want to create in our Google Sheet, either with built-in functionality, or with an extension like Sheetgo.
We have 2 sheets with multiple of the same columns (properties) and rows (users). The problem is that only one of the sheets is a trusted source for one column’s data (“source sheet”), and the other sheet has empty or outdated values for the same column (“outdated sheet”), and we need both sheets to have this column match values in rows that have a matching value for another column across both sheets (in our case, an “email” column). After they’re matching, we want to change the formula to sync any changes made for that column between both sheets.
Here’s an obfuscated data example:
Source sheet:
https://docs.google.com/spreadsheets/d/1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o/edit?usp=sharing
Outdated sheet:
https://docs.google.com/spreadsheets/d/1ckoCh8gMwt2QeBRH1dB2dyFPJUukrjQ-SCgucTL8rhc/edit?usp=sharing
In the example, we’re looking for a formula that would allow us to have a “Type” column value injected into the Outdated Sheet’s Type column, based on both sheet’s matching Email column value. And then, have it so if a row’s “Type” value changes in either doc, the other doc follows.
What formula or extension would I use to go about this? Any help appreciated, thanks!
I tried to create a VLOOKUP and MATCH formula, but I couldn't yet figure out how to have the function first LOOKUP into the Source Sheet, then inject it into the Outdated Sheet based on a matched email column value. Sheetgo made the LOOKUP easier, but I still couldn't figure out how to do an exact operation.
Use importrange() and vlookup(). Put this formula in cell A1 of the target spreadsheet:
=arrayformula(
lambda(
import,
iferror(
vlookup(
C1:C,
{ index(import, 0, 3), index(import, 0, 1) },
2, false
)
)
)(
importrange("1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o", "Sheet1!A1:F")
)
)
I have the following formula
SUMIFS(Sheet1!I2:I12,Sheet1!H2:H12,"1111-1111",Sheet1!B2:B12,"1111")
I want the Sheet1 from a separate workbook (not sheets in the same workbook), how can I do this?
My workbook1 is https://docs.google.com/spreadsheets/d/1L4t2xkmHPAOn8uGT3bFy56UMWrZaHsyq4FlOh6uR2g0/edit?usp=sharing
I want to do following in workbook2
= SUMIFS(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1VayuaMlSMvkhBKKuQnRTuTwk6kshFWQanWxa5KWh2ag","Sheet1!I2:I12"),IMPORTRANGE("https://docs.google.com/spreadsheets/d/1VayuaMlSMvkhBKKuQnRTuTwk6kshFWQanWxa5KWh2ag", "Sheet1!H2:H12"),"1111-1111",IMPORTRANGE("https://docs.google.com/spreadsheets/d/1VayuaMlSMvkhBKKuQnRTuTwk6kshFWQanWxa5KWh2ag", "Sheet1!B2:B12"),"1111")
use:
=QUERY(IMPORTRANGE("1L4t2xkmHPAOn8uGT3bFy56UMWrZaHsyq4FlOh6uR2g0", "Sheet1!A:I"),
"select sum(Col9)
where Col8 = '1111-1111'
and Col2 = 1111
label sum(Col9)''")
You can use the IMPORTRANGE formula to pull data from another sheet.
You can either embed the IMPORTRANGE in your formula in order to pull directly from it, or you can use the formula on its own in a new sheet, and pull from the sheet located within the same Spreadsheet for ease of access and a shorter formula overall.
Updating the spreadsheet you are pulling from will automatically update the data coming from the IMPORTRANGE formula.
For example:
A1 contains the basic formula =importrange("https://docs.google.com/spreadsheets/d/1I8BiB-2gSFueLIKiGsMY-URLOpnB8QzbUrx8/edit#gid=0", "Sheet1!I1:I12")
while B1 contains =sum(importrange("https://docs.google.com/spreadsheets/d/1I8BiB-2gSFueLIKiGsMY-URLOpnB8QzbUrx8/edit#gid=0", "Sheet1!I1:I12"))
Make sure you replace the URLs above with the one for the sheet you are trying to pull from
I think you need to use IMPORTRANGE to bring in the columns you want to your active sheet. You can either import the data first and then use a formula in another cell to work with it, or you can use IMPORTRANGE inside your SUMIF formula.
EDIT: Here's a workbook that has it working.
The formula in Sheet1!A1 is =IMPORTRANGE("https://docs.google.com/spreadsheets/d/1L4t2xkmHPAOn8uGT3bFy56UMWrZaHsyq4FlOh6uR2g0/edit?usp=sharing","Sheet1!A1:I12"), which pulls the data from your shared workbook1 into this sheet.
The formula in Sheet2!A2 is =SUMIFS(Sheet1!I2:I12,Sheet1!H2:H12,"1111-1111",Sheet1!B2:B12,"1111")
You could also put the SUMIFS formula on Sheet1 if you prefer. It's 2 steps instead of one, but it works!
I recently noticed a mistake in my calculation, and I've identified the root cause of the problem: it seems that I mistakenly used the SUMIF function in Google Sheets' ARRAYFORMULA.
I have the sample spreadsheet here.
I wrote the ARRAYFORMULA function that results in column C, which I thought would be the same with the formula in column B.
The formula in column C:
=ARRAYFORMULA(SUMIF(H$3:H$6&I$3:I$6,"<="&A3:A31&">="&A3:A31,G$3:G$6))
The formula in column B:
=SUMIFS(G$3:G$6,H$3:H$6,"<="&A3,I$3:I$6,">="&A3)
In essence, I want to get the value for each date based on predefined values with their own periods.
Please, use this formula in the cell C3:
=ARRAYFORMULA(MMULT(IF((A3:A31>=TRANSPOSE(H3:H5))*
(A3:A31<=TRANSPOSE(I3:I5))=1,TRANSPOSE(G3:G5),0),ROW(G3:G5)^0))
I made a new tab called MK.Help and erased all the other formulas. then i put this formula in C3:
=ARRAYFORMULA(ARRAY_CONSTRAIN(MMULT(N(A3:A>=TRANSPOSE(A3:A)),MMULT((A3:A>=TRANSPOSE(H3:H))*(A3:A<=TRANSPOSE(I3:I)),N(G3:G))),COUNTA(A3:A),1))
Does that work for you?
I'm trying to embed a countif into an array formula in Google Sheets. I'm using the countif command to count the number of cells on another page with a given text string, stored in column B. Column B just contains a list of titles. The concatenate portion does a general keyword lookup.
Here is the formula that does not work. It just returns a 0 in each cell, which tells me the countif statement is failing.
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*"))),""))
If I pull out the countif statement, it works fine by itself.
=COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*")))
I have even tried referencing B2:B in place of the B2 cell reference, but that does not work. What did I do wrong in the array formula statement?
Have you tried using & instead of the CONCATENATE function and referencing to B2:B in place of only B2?
The formula should look like this:
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,("*" & B2:B & "*")),""))
It works for me.
This is my 'Registrations' sheet:
And this is the sheet where the formula is written:
I'm trying to do something that would be simple in Excel, but in Google Sheets you have to use INDIRECT in a formula to get a value from a different sheet.
All I want to do is pull the value in Sheet1!B2 if Sheet1!A2 equals A2.
I tried it several ways, below are a couple
=IF(Sheet1!A2=A2),INDIRECT("Sheet1!B2")
and
=INDIRECT("Sheet1!B2")IF(Sheet1!A2=A2)
in Google Sheets you have to use INDIRECT in a formula to get a value from a different sheet
is not correct.
Try:
=if(A2=Sheet1!A2,Sheet1!B2,"")
If that does not return the content of Sheet1!B2 then A2 does not equal Sheet1!A2 (even if they look the same).