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)
Related
Hi everybody I am trying to query an already formatted google sheets, I am able to filter some of those data (I used =query(x,select * where ... )). The output I get is the following:
may
may
june
june
july
july
july
planned
name
1
0
1
1
2
3
1
Now I want to refer to all the numbers under may (or june or july) in order to do some operation. I can' t just select the value I want because I need to automate it.
How can I get all the columns containing a specific marker(in my case the name of the month)? If it is not possible can you suggest me a different way to do that ? (I am not very experienced with google sheets or excel)
Since query can't select rows, you'd transpose it first and then select the columns you want and then retranspose it back, if needed:
Input:
may
may
june
june
july
july
july
planned
name
1
0
1
1
2
3
1
Formula(select columns >0):
=QUERY(TRANSPOSE(A27:I28),"Select * where Col2>0")
Output:
planned name
may
1
june
1
june
1
july
2
july
3
july
1
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)
I am trying to query data from a sheet matching two conditions. However, when there is more than 1 row in the data matching my condition the query only returns the first result. How do I make sure it returns ALL rows matching the conditions?
I tried changing the single and double quotes, capital letters, changing the format of the data but nothing worked.
The query:
query(Raw!A1:J29041, "select B,C,D,E, sum(F) where B='"&sheet1!A2&"' and E='good source' and not C='2016' GROUP BY B,C,D,E")
Example of data:
Client Year Month Source Count
Client a 2019 July other source 1
Client a 2019 July good source 2
Client a 2019 July bad source 22
Client a 2019 July good source 63
Client a 2019 July another source 1
Client a 2019 July another source 8
Desired output for this data:
Client Year Month Source sum
Client a 2019 July other source 65
numbers shouldn't be enclosed with single quotes
try:
=QUERY(Raw!A1:J29041,
"select B,C,D,E,sum(F)
where B="&sheet1!A2&"
and E='good source'
and not C='2016'
group by B,C,D,E", 1)
or:
=QUERY(Raw!A1:J29041,
"select B,C,D,E,sum(F)
where B="&sheet1!A2&"
and E='good source'
and not C=2016
group by B,C,D,E", 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")
I have an easy-to-append monthly purchase log:
month prod count
-----------------
jan water 10
jan bread 20
feb bread 2
feb water 1
And I want to get a friendlier summary table:
prod jan feb
-------------
water 10 1
bread 20 2
Any idea how I can get this raport with new months in log appearing automatically as new columns?
I managed to get the month heads with a =ArrayFormula(TRANSPOSE(UNIQUE(FILTER(log!A2:A, log!A2:A<>"")))) and I am ok with entering the prod column by hand but I only managed to have a formula per column for count. And that means I need to drag the formula with each new month added to the log...
Any ideas? Thanks!
Try this formula:
=QUERY(A:C,"select B, sum(C) where A <> '' group by B pivot A")
See more info here:
https://developers.google.com/chart/interactive/docs/querylanguage
Use number of months instead of names to get 1, 2, 3 from feb, jan ordered alphabetically