Google tabs IMPORTRANGE with SUMIF problems - google-sheets

I know it has already been a few times discussed topic, but I haven't found any help that would suit my problem yet.
I'm trying to make a sum of numbers in one column in a different Google sheet. The problem is I need to sum only those numbers happened in chosen month. I have the number of the month in the sheet where I need the function, and I have the month specifikation in a column next to the numbers.
All I came to till now is this (after many totally different codes):
=sum(query(IMPORTRANGE("xyz";"Výkaz!B23:C125");"select Col2,Col3 where "col2=G4";0)"))
G4 is the chosen month I have in the same sheet as this code
Please, could you help me figure this out? Thank you

Google Sheet 1 (TabName = "externalTab")
Google Sheet 2 (TabName = "InternalTab")
Use importrange to pull the all data from "externalTab" to "Internal Tab". Then just use a sumifs formula to add up values based on your criteria.
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/1sLPGZkAVlxWfjhDMU9oa_cww0AI570Rtem0XCoOx0AE", "'externalTab '!A1:AF2000")
Alternatively use the following formula. Integers to be summed are located in column a/Col1 and Months are located in column b/Col2. There is one header row on the spreadsheet and we are adding up all the Integers that correspond to the month June.
=sum(query(importrange("https://docs.google.com/spreadsheets/d/1sLPGZkAVlxWfjhDMU9oa_cww0AI570Rtem0XCoOx0AE","a1:b1000"),"select Col1, Col2 WHERE Col2 = 'June'",1))

Related

Google Sheets formula recalculation quirk

This may simply be a convoluted duplicate of an existing question, and I have been able to find one or two issues that match what I'm seeing here, but I am very curious to see if the cause is just user error on my part or if this is something I am just not aware of.
I have a worksheet titled Sheet1 with 999 rows. On this sheet in cells A3, B3, and C3 down are Year values (2021), Month numbers (1, 2, 3, etc.), and Quarter (Q1, Q2, etc.). In cell D, I have the following long but simple formula:
=SUMPRODUCT((MONTH(INDIRECT("TestSheet ("&C2&" "&A2&")!$C$3:$C$999"))=B2)*(YEAR(INDIRECT("TestSheet ("&C2&" "&A2&")!$C$3:$C$999"))=A2)*(INDIRECT("TestSheet ("&C2&" "&A2&")!$E$3:$E$999")))
What this formula does is sum the monetary values from sheets with variable names by month (INDIRECT is used to refer to sheets with the name "TestSheet (x y)", where x is the Quarter value and y is the year (ie: "TestSheet (Q1 2021)").
This formula functions as intended, and correctly sums the values on the variable sheet names when those sheets exist. The issue I'm running into is that it seems to take a length of time for Sheets to identify that a sheet exists, even when "On change and every minute" is selected under the Calculation tab under Spreadsheet Settings. From testing on a fresh workbook in which this formula is the only one present and there are no other formulas present that could be slowing down the recalculation, the cell values do not appear to update at all even an hour after the relevant cells have been updated with data.
Is there any indication based on what I have so far that stands out as a possible cause? Any suggestions would be appreciated.
try:
=INDEX(SUMIF(TEXT(
INDIRECT("TestSheet ("&C5&" "&A5&")!C2:C"), "yyyyM"), A5&B5,
INDIRECT("TestSheet ("&C5&" "&A5&")!E2:E")))

Copy a NB.SI formula into a Google Sheets sheet

I am turning to you today for help with a problem on Google Sheets.
I receive this data from a Google Sheets form: An answer (0 or 1) to 5 different questions.
I would like to calculate in column A (in green) the scores out of 5 for each row, as soon as a new row is added by the form.
I tried to use the ARRAYFORMULA() function but it does the count for all the cells in the range and not just row by row:
Do you have an idea to have a score out of 5 for each line of question and have it apply to the whole file as soon as a new line is added by the Google Form?
Thanks for your help
If you want to use COUNTIF (English correspondance for NB.SI), modify your formula to:
=ARRAYFORMULA(COUNTIF(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
or for your regional settings:
=ARRAYFORMULA(NB.SI(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
You can get a row-by-row sum with sumif() like this in cell A3:
=arrayformula( sumif( if(column(B3:F), row(B3:F)), row(B3:F), B3:F) )
This formula uses open-ended range references so it will create results all the way down to the end of the sheet. To limit that, use a range reference like B3:F100 instead.

Combing base data set for a formula from two *other* Google sheets

We have hit the dreaded 5 million rows limit which is so small for any semi-serious data.
We have an important ArrayFormula piece in one of our worksheets (tab) currently that summarizes the data from another worksheet in the same file where time series data is kept with dates. This is our current function:
=ArrayFormula(SUMIFS(DataSheet!$B:$B,
MONTH(DataSheet!$A:$A), 1,
YEAR(DataSheet!$A:$A), 2020)
)
Explanation: This basically summed all of column B in the DataSheet tab for the month of Jan 2020 based on date found in column A of that sheet.
However, this worksheet of data that is now running close to that row limit. We can move it to another Google Sheets file, and refer to the same data via IMPORTRANGE.
The question then is how to refer to that data instead of the DataSheet!$A:$A in the above old formula? Will this reference be replaced by the entire IMPORTRANGE function?
Old:
=ArrayFormula(SUMIFS(DataSheet!$B:$B,
MONTH(DataSheet!$A:$A), 1,
YEAR(DataSheet!$A:$A), 2020)
)
New:
=ArrayFormula(SUMIFS(IMPORTRANGE(filename, rows)!$B:$B,
MONTH(IMPORTRANGE(filename, rows)!$A:$A, 1,
YEAR(IMPORTRANGE(filename, rows)!$A:$A, 2020)
)
This does not work of course, because we cannot have the exclamation ! followed by the column in an importrange. Any other thoughts?
Try this in cell A1 on a fresh, brand new tab somewhere:
=ARRAYFORMULA(QUERY(1*TEXT(IMPORTRANGE("[spreadsheet key]","Sheet1!A:B"),{"mmmyyyy","0.00"}),"select Col1,SUM(Col2) where Col2<>0 group by Col1 order by Col1")
The "spreadsheet key" is the combination of letters and numbers after the "/d/" and before the "/edit..." in the URL of your source sheet.
Obviously, you'd also replace "Sheet1!A:B" with whatever the real tab/column reference is.
Then, select all of Column A and from the Menu choose Format>Number>More Formats>Custom Number Formatting, Then this in the dialog box:
mmmm yyyy
You want to IMPORTRANGE from two different sheets in a different spreadsheet.
While the following formula will import data from both sheets, it will also import the blank rows, so you might have to scroll down hundreds of rows in order to see the data from the second sheet (and this might give your the wrong impression that the second sheet is not getting imported):
{
IMPORTRANGE("SPREADSHEET_ID","CurrentMonth!$A:$J");
IMPORTRANGE("SPREADSHEET_ID","All2020!$A:$J")
}
You can use QUERY in order to filter out blank rows:
=QUERY(
{
IMPORTRANGE("SPREADSHEET_ID","CurrentMonth!$A:$J");
IMPORTRANGE("SPREADSHEET_ID","All2020!$A:$J")
},
"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col1 DESC"
)
Note:
I thought you'd like to sort the data according to the date in column A, please remove ORDER BY Col1 DESC if that's not the case.

Google Sheets sum rows with the same first cell value grouped by first row value

I have dynamic data for an online shop with sales by product, by week split into columns:
I want to create a header row of the unique weeks and summarise the total sales by product by week in a dynamic table using query and or array formula if possible. However, Arrays and Queries seem to be designed for data exclusively in columns so maybe I need to transpose it in some way? Any ideas?
you can do:
=QUERY(B2:E, "select B,C+D,E label C+D''", 0)
or:
=ARRAYFORMULA({IF(B99=C99, B100:B+C100:C, B100:B),
IF(C99=D99, C100:C+D100:D, C100:C),
IF(D99=E99, D100:D+E100:E, D100:D),
IF(E99=F99, E100:E+F100:F, E100:E)})
Okay, so I took my own advice and did a transpose to get the data into a state that Query can work with and then re-transposed it back to get the format I wanted. However, it's not exactly dynamic as I'd have to edit the formula if we added or took away any products.
=Transpose(query(transpose(A2:E13),"Select Col1, Sum(Col2), Sum (Col3), Sum(Col4), Sum(Col5), Sum(Col6) ,Sum(Col7), Sum(Col8), Sum(Col9), Sum(Col10), Sum(Col11), Sum(Col12) group by Col1",1))
Which produces a nice tabular result:
Any ideas how to make the formula more dynamic?

Sum across sheets with multiple conditions

I have two sheets in the same spreadsheet: "Quest 1.1" and "Quest 1.2".
On the respective columns in QUEST 1.2, I want to sum the total revenue for each company based on the year in the date column in QUEST 1.1. I tried using
=SUM(FILTER(FILTER('QUEST 1.1'!C1:C11,YEAR('QUEST 1.1'!B1:B11)=2015),A2:A11="Company A")) but I got a "Formula parse error".
Thanks in advance!
Note: I added a header row to Quest1.1. (note the difference in offset). You should be able to tweak it to fit your needs fairly easily. It basically tells Google sheets that, SUM the Amount if the company matches column A AND if the date is on or greater than YEAR-01-01 and on or before YEAR-12-31.
Put the following into cell B2 and fill down and fill right as needed.
=SUMIFS('Quest 1.1'!$C$2:$C$12,'Quest 1.1'!$A$2:$A$12,$A2,'Quest 1.1'!$B$2:$B$12,">="&DATE(RIGHT(B$1,4),1,1),'Quest 1.1'!$B$2:$B$12,"<="&DATE(RIGHT(B$1,4),12,31))

Resources