I'm trying to sum values across multiple Google Sheet spreadsheets (workbooks) that are grouped by dates. For example, I want to sum all the Delta values for March 2, 2020 across multiple spreadsheets and each spreadsheet will have 0 or more values for that date.
Here's an example with 2 spreadsheets:
Spreadsheet 1:
Date Start Stop Delta
Mon 02Mar20 16:51 16:56 0:05
Mon 02Mar20 16:56 17:00 0:03
Tue 03Mar20 18:45 18:49 0:03
Tue 03Mar20 19:04 19:06 0:01
Spreadsheet 2:
Date Start Stop Delta
Mon 02Mar20 8:38 8:49 0:11
Tue 03Mar20 4:47 4:50 0:03
Tue 03Mar20 17:42 17:55 0:13
Tue 03Mar20 17:58 18:45 0:47
Tue 03Mar20 18:53 19:03 0:10
I want to have a dynamic sum of the Delta columns across spreadsheets by each day in a separate spreadsheet. So here's what I would like to autogenerate. Specifically, the sum of the Delta values for Spreadsheet 1 and Spreadsheet 2 for each day (0:08, 0:11, 0:04, 1:10):
Date Total Spreadsheet 1 Spreadsheet 2
Mon 02Mar20 0:19 0:08 0:11
Tue 03Mar20 1:14 0:04 1:10
I tried using IMPORTRANGE but I'm not sure how to make the sums dynamic for each day. I don't know ahead of time how many entries I'll have for each date in Spreadsheet 1 and 2 so I want to have a way to auto determine how many rows to sum up each day for Spreadsheet 1 and 2. I'm guessing I would need to use QUERY or FILTER to filter all the imported values from IMPORTRANGE but I'm not sure how to do that.
I made an easy dataset to be sum up. Got a Spreadsheet like this:
As you can see, the total sum values for 2nd march would be 2 and for 3rd March would be 20.
In a different Spreadsheet, got my dashboard:
The formula I've used in B2 is:
=SUMPRODUCT(--(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!A1:A4")=$A2);IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!B1:B4"))
This is how it works:
--(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!A1:A4")=$A2) will compare the values of column A in Workbook 1 with the date in column A in my main dashboard. Because we've used a double unary operator this will return an array of 1 and 0 if there is a match or not (in this case, it will be an array like {1;1;0;0}
IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!B1:B4") will return as array the values of column B in Workbook 1, in this case it will return {1;1;10;10}
SUMPRODUCT will multiply both arrays and sum up the values, in this case {1;1;0;0} * {1;1;10;10} = {1;1;0;0} and the sum up of this final array is 2.
Same logic applied to second date, we would obtain {0;0;1;1} * {1;1;10;10} = {0;0;10;10} -> 20
Just add each workbook in 1 different column with same formula, and then do a normal sum up in your main dashboard to get the Grand total sum for all values in all workbooks for a specific date:
Hope this helps.
NOTICE: Of course, this method will work only if your dates are dates (not strings/texts) and the times in Delta are date/times too (not strings/texts)
Related
I have a googlesheet (sheet 1) which looks like this:
contents contains a column with Months
May 2021
June 2021
July 2021
August 2021
September 2021
October 2021
November 2021
December 2021
January 2022
February 2022
March 2022
April 2022
May 2022
June 2022
Each month / cell in column A (sheet 1) all link to another sheet within the workbook containing the data for each month, all data has different rows, so to summarise each month, I want a formula like this:
=sumif(indirect(A4,&"!A:A"),"ProductA",(indirect(A&"!B:B")))
where A4 references January 2021, and this is linked to sheet January 2021, ProductA is in column A of each monthly breakdown (all sheets after sheet 1), and the number of these in column B.
I want to be able to drag this formula down, and have the sheet look for the sum of ProductA across all months, using Column A in sheet 1 to reference the sheet it should look in, i.e. the month.
Does this make any sense?
I can add more info, apologies for the waffle.
Sheet 2 for example contains Month1 data and looks like this:
Category (Ticket) Count Thread Time
prod1 5 22 8395:35:00
prod2 67 5411 644:24:00
prod3 544 55 18283:24:00
prod4 56 546546 97093:52:00
prod5 75 646 38238:11:00
Here is a formula that should work for you:
=arrayformula(sumif(indirect($A2&"!A:A"),C$1,(indirect($A2&"!B:B"))))
You can place this into cell C2, and then copy it down and across.
The issue with your formula was first that you had (indirect(A&"!B:B")), instead of (indirect(A2&"!B:B")).
Secondly, you need to make sure that there's no extra space after your values.
In the above image, you have an extra space after prod3, so when using the SUMIF and trying to match the value, it was not working. If something is resulting in 0 where it shouldn't be, make sure to check that first. I have found that prod4 and prod6 both have the same issue.
A company has a list of clients, i, all of which delay their payments by X_i. The problem is to create a spreadsheet that will show the sum of positive cashflows for a given day, where the delay of incoming cashflows can be manually adjusted.
The input is:
Date
Amount Due $
Client
Expected Delay (Days)
01
100
A
2
02
5
B
0
02
30
C
1
03
50
B
0
The output needs to be:
Date
Total Inflows $
01
0
02
5
03
180
How can I code this in Google Sheets?
Use for date:
=UNIQUE(A2:A)
and for totals:
=ArrayFormula(IF(LEN(F2:F),SUMIF(A2:A+D2:D,F2:F,B2:B),))
if in date column you have text values you need convert it to real dates and format as you want
I have a workbook where I track game stats for my local community. I added a chart that changes upon a few selections and I use filter to get the desired result. The data comes from a sheet where I use query to calculate month to month differences (since I could not find this easily done with google's provided pivot options). One of the query's looks like this
=query('Response Edits'!1:1112,"select A,B,C WHERE A IS NOT NULL AND NOT H matches '"&textjoin("|",TRUE,query('Response Edits'!1:1112,"select min(H) WHERE A IS NOT NULL group by D",0))&"' order by D, C ASC",0)
A converts the month value in the timestamp to the correct survey month (e.g. a 2020-07-01 would be for 06 survey and 2020-07-29 would
be for 07 survey)
B converts the year value in the timestamp to the correct survey year
C is the timestamp of the survey submission
D is the player name
H is the player XP of the survey submission (I use this as a lazy solution since it only increases and because I could not figure out a
way to include the key phrase date using multiple datetime e.g.
NOT C matches date texjoin("|",TRUE,"select min(C)...") did not work)
the textjoin is just to remove the earliest date submitted because it would not have a month to month value. Here is a portion of the output of the query above and another query which I believe is correct:
7 2020 2020-07-31 23:18:48 ... 6873449 198 11610
8 2020 2020-08-31 22:15:53 ... 7789713 175 8732
9 2020 2020-09-30 23:03:12 ... 5994347 139 8932
When I close the the sheet and reopen it I notice that my chart has only 0 values because my sheet with the query functions is only outputting 0. The above query and my other query have also given a different output, which I have provided a portion for below:
6 2020 2020-06-30 22:04:02 ... 0 0 0
7 2020 2020-07-31 23:18:48 ... 0 0 0
8 2020 2020-08-31 22:15:53 ... 0 0 0
9 2020 2020-09-30 23:03:12 ... 0 0 0
I am new to using query, but the formula seems correct, because if I change the last 0 in the formula (which is the option for header) to 1 and then back to 0 I get the desired result.
Tl;dr Why does the queried data not output correctly when I close and reopen a workbook? And why does it output correctly after the formula is changed and changed back (including selecting undo)? Is it potentially textjoin or matches causing the problem in the query?
try to run this:
=QUERY('Response Edits'!A1:H1112,
"select A,B,C
where A is not null
and not H matches '"&TEXTJOIN("|", 1,
QUERY('Response Edits'!A1:H1112,
"select min(H)
where A is not null group by D", 0))&"'
order by D, C", 0)
so I have this query that pulls all the data from the previous month but I would like it to pull the previous 6 months
=query(Insiders!A4:L,"Select * where month(C)=month(now())-1",1)
Taking the current month as July, if you want to display results where the date in Col C is in Jan 2021 to June 2021 inclusive, then try this:
=arrayformula(query(Insiders!A4:L,"Select * where C>= date '"&text(eomonth(today(),-7)+1,"yyyy-mm-dd")&"' and C< date '"&text(eomonth(today(),-1)+1,"yyyy-mm-dd")&"' ",1))
Currently (at 10/7/2021), text(eomonth(today(),-7)+1,"yyyy-mm-dd") = 2021-01-01
text(eomonth(today(),-1)+1,"yyyy-mm-dd") = 2021-07-01
These are the two date search ranges.
You can alter the eomonth() function parameters -7 and -1 to move the months into a different period.
try:
=QUERY(Insiders!A4:L, "where month(C)+1="&MONTH(TODAY()), 1)
I am using Google Sheets and am trying to find the largest value for cells that contain a specific year.
Example:
A B
DATE Value
1 jan 1875 4000
1 jan 1880 800
5 feb 1875 3500
6 jun 1875 2500
I have read about the MAXIFS function but am unsure how to apply it in this situation.
MAXIFS(B2:B4;A2:A4;1875) only returns "0" when I want it to return "4000" in B2.
I have tried substituting the "1875" in the formula with "YEAR(1875)" but it doesn't work.
It might be an issue with the dates being before 1900 but I've tried using years after 1900 as well, still it won't work.
Anyone here who knows?
I suggest a query instead of MAXIFS:
=query(A:B,"select max(B) where A contains 1875")