I have an order sheet in which Column K has delivery date, column I has the qty. I want a weekly order summary.
I used the below in column J
=ArrayFormula( IF(ROW(A:A)=1, "Week", IF(not(isblank((I:I))), weeknum(K:K),"")))
In the pivot report sheet I use the below formula (in M2:M) to show the starting date of the week (with "2019" fed in M1)
=DATE($M$1, 1, -3 + 7 * K2 - WEEKDAY(DATE($M$1, 1, 4), 2) + 1)
This worked well as long as the dates are within year 2019.
But, now some orders of 2020 have come in and the weeknum has become 1 - this creates problems while sorting in pivot table and there is weeknum 53 and the December last week and Jan first week are shown as two different weeks.
The starting date of the week is also wrong for the dates belonging to year 2020 (due to 2019 fed in M1).
I tried combining year and week in column J by array formula
=ArrayFormula( IF(ROW(A:A)=1, "Week", IF(not(isblank((I:I))), 52*year(K:K)+weeknum(K:K),"")))
This solved part of the problem in pivot table (the last week problem disappeared) but, how to get the first date of the week near the week number?
Or suggest another way to get weekly summary and print the first day of the week (Monday) near the weeknum in the pivot table.
The below query solved the problem partially. It is able to sort correctly. But, the 53 rd week and 1 st week are still seperate and i am not able to display the first day of the week.
=ARRAYFORMULA( QUERY({ YEAR(Plan!K2:K)&" "&WEEKNUM(Plan!K2:K), Plan!I2:I, YEAR(Plan!K2:K)+WEEKNUM(Plan!K2:K)*0.01923076923}, "select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col1 label sum(Col2)''", 0))
Example sheet
https://docs.google.com/spreadsheets/d/1FT1pk3BrQ_VBLpJWif9A5z0LFIB4pZugh0kLM-QtL_s/edit?usp=sharing
The report is in Daily_Plan sheet in K1