I have this row in Google Sheets with the year and Week yyyy-ww which starts at week "0".
A B C D E
1 2022-00 2022-01 2022-02 ... 2023-00
How do I convert to a "Date Range" like this in Google Sheets?
A B C D E
1 Dec 26 - Jan 1 2 Jan - 8 Jan 9 Jan - 15 Jan ... ...
I'm not sure if this is what you are looking for but this is a math formula that gets you your results. Paste it in A2 and it will spill over through all the columns.
=ARRAYFORMULA(IF(A1:1<>"",TEXT(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)-6),"mmm dd")&" - "&TEXT(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)),"mmm dd"),""))
You could then copy and paste the values over your original row. Assuming you want to convert your current format over to this new format permanently.
If you are looking for a way to literally format the cell, I do not believe that is possible from a yyyy-ww format.
UPDATE:
If curious, a shorter version using LAMBDA would look like:
=ARRAYFORMULA(LAMBDA(a,IF(a>0,TEXT(a,"mmm dd")&" - "&TEXT(a+6,"mmm dd"),""))(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)-6)))
can you try this out:
=BYCOL(A1:G1,LAMBDA(ax,LAMBDA(s,w,LAMBDA(z,iz,IFS(iz=1,text(MAX(z)-6,"MMM D")&" - "&text(MAX(z),"MMM D"),iz=53,text(MIN(z),"MMM D")&" - "&text(MIN(z)+6,"MMM D"),(iz<>1)+(iz<>53),text(MIN(z),"D MMM")&" - "&text(MAX(z),"D MMM")))(FILTER(s,w=--RIGHT(ax,2)+1,YEAR(s)=--LEFT(ax,4)),FILTER({w},w=--RIGHT(ax,2)+1,YEAR(s)=--LEFT(ax,4))))(SEQUENCE(DAYS("12/31/2025", "1/1/2020")+1,1,DATE(2020,1,1)),INDEX(WEEKNUM(SEQUENCE(DAYS("12/31/2025", "1/1/2020")+1,1,DATE(2020,1,1)))))))
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.
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")
can it be that Google Sheets is not calculating right?
=DAYS360(DATE(2016;12;31); date(2017;1;1))
is 1 and also this is 1 but is should be 2:
=DAYS360(DATE(2016;12;30); date(2017;1;1))
Whats wrong here?
I think it is because of the formula that is set to 360 days. It is said here that DAYS360 - Days between two dates on a 360-day year. So it means that you will only have a 30 days a month not including the date 31 in the months of (Jan, March, May, July, Aug, Oct and Dec).
For example, you use this =DAYS360(DATE(2016,10,25), date(2016,10,30)) so the expected output is 5 - which is correct
If you use =DAYS360(DATE(2016,10,25), date(2016,10,31)) the expected output is 6 - because you specify the date 31.
But, if you use =DAYS360(DATE(2016,10,25), date(2016,11,3)), the output is 8 not 9 - because it did not include the date 31.
I hope I explained it clearly.