How to connect two google sheet workbooks using SUMIFS? - google-sheets

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!

Related

Conditional Formatting & Importrange using 2 spreadsheets

I am requiring specific cells of a Google spreadsheet to be conditionally formatted based on information in a different spreadsheet.
The information is input into column J of a spreadsheet titled 'Haulage' and in a worksheet with the same name. I then require any cell in the range AE15:AH101 in a spreadsheet titled 'EMU Database' and in a worksheet titled '350' to be highlighted in a colour should the information in this cell match the information input into column J of the 'Haulage' spreadsheet/worksheet
ie '271' is in cell AE15 of the worksheet '350' (in 'EMU Database' spreadsheet) and when I input the same value into cell J3 of the worksheet 'Haulage' (in the 'Haulage' spreadsheet), AE15 is highlighted in the chosen colour.
I have tried using the following formula in the conditional formatting custom formula:
=A15=IMPORTRANGE("1AGMJxw5D5TNFI19dvpPCT0Jl6QNu5rRX1bcLqHYJ0-w", "Haulage!J3:J")
But not been able to make it work unfortunately.
For reference, both of the spreadsheets have been linked together and access has been granted between the 2 spreadsheets
Progress report:
I have been playing around with the importrange options in making this conditional formatting work and I have managed to get it to work by importing the data into the same spreadsheet and then using a formula between worksheets as detailed below:
Data from "Haulage" spreadsheet and "Haulage" worksheet within this spreadsheet is transferred to "EMU Database", into a worksheet titled "Sheet5" using the standard importrange function. In the cells I require the custom formula to work I have then used the following custom formula:
=match(AE15,indirect("Sheet5!A1:A"),)
This offers a solution to my problem and works as I require it, however I would still like to find a solution to avoid having to transfer the data from one spreadsheet to another before the formula works. I have tried to amend the above formula in a number of ways to incorporate an IMPORTRANGE but without success. My most recent failing is below:
=match(AE15,indirect,importrange("1AGMJxw5D5TNFI19dvpPCT0Jl6QNu5rRX1bcLqHYJ0-w", "Haulage!J3:J"),)
If anyone has any ideas on how to make the importrange work on this match formula it would be appreciated as it keeps things tidier for me than having extra worksheets with duplicate data from another spreadsheet
Follow up information for #player0
Links to the test versions of the relevant spreadsheets are below:
Haulage SS = https://docs.google.com/spreadsheets/d/1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4/edit?usp=sharing
EMU Database SS = https://docs.google.com/spreadsheets/d/1poWzun1TvIhdlrHQyM_tSvJzEHFDpvZz7O-Ta0mvAR8/edit?usp=sharing
Within the "Haulage" spreadsheet, only the 'Haulage' worksheet is of interest - please disregard the other worksheet.
Within the "EMU Database" spreadsheet you will find my current conditional formatting in cell range AE15:AO71 of worksheet '390'. This formatting is linked to the worksheet titled 'Sheet5' which contains the data that I have used the importrange formula (see cell A1 of this worksheet) to pull from cells J3:J of the Haulage spreadsheet.
Basically, what I require of the conditional formatting is for any data in cell range AE15:AO71 of the '390' worksheet which matches data entered in cell range J3:J of the "Haulage" spreadsheet to be highlighted with a coloured box - but I want this to happen without the need for the extra worksheet with the imported data in
try:
=MATCH(A1, FILTER(
IMPORTRANGE("1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4", "Haulage!J3:J"),
IMPORTRANGE("1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4", "Haulage!J3:J")<>""), 0)

How to make a dynamic import command from one sheet to another in google sheets

I want to build a tool that lets me insert a spreadsheet in a given format into sheet1. Then it takes some data and inserts it into a specified location in sheet2.
I am using functions in the following format at the moments:
=Sheet1!AI2
For every column, I need the data from all rows i.e sheet1 A1 to sheet2 B2, Sheets A2 to sheet B3 ...
There are hundreds of rows and I don't want to copy-paste it and manually change the row number.
Is there a way to do it like this:
=Sheet1!AI(rownumber-1)
That way it would work for all rows.
Thanks for taking the time and reading this!
Try putting this in Sheet2!B2
=ARRAYFORMULA(Sheet1!AI:AI)
or this (it will give you the same result):
=INDEX(Sheet1!AI:AI)
Be sure that Sheet2 has at leas one more row than Sheet1. Google Sheets will automatically add 500 new rows, but if the numbers of rows in those sheets are codependent than rows will be added in a loop up until the limit.

How to select the correct range in Google Sheets

I have data in Google Sheets and I'm trying to run a pivot table. The problem is that the title is on cell a1 but data doesn't start until a60. I don't want to include the data in cells a2 through a59. If I run the pivot on a60 to a102 then it thinks a60 is the title and doesn't include it. How do I tell sheets to use a1+a60-a102?
if this would not be a pivot table you would need to do this:
={a1; a60:A102}
the best workaround you can ever have is to paste this on some new sheet (which you can hide) and then build your pivot table from there

How to get a value from a different sheet if two cells match in Google Sheets

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).

How to use Sumif using range from a complete different Googlesheet/doc

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&"'" ) )

Resources