I'm trying to calculate weekly sums in a single column, but I'm having trouble writing the formula. I'm found the the weeknum for every date in the year, but I can't find a way to sum up values if they have the same weeknum.
Link to my spreadsheet: https://docs.google.com/spreadsheets/d/1WIeBpRndO9ZBlkCcWQuNO1X4e9I6bGeQiYDTZqhaOeA/edit#gid=0
I'd like column "D" to automatically calculate the weekly sum using an array formula -- is there a way to do this?
This thread introduces the problem: Calculate weekly and monthly total in spreadsheet.
Chang sum() to sumif()
=ARRAYFORMULA(IF(ROW(A:A)=1,"Weekly Sum", IF(WEEKDAY(A:A)=7, sumif(C:C,C:C,B:B),)))
You have: A2:A with dates and B2:B with values. So:
F2=arrayformula(if(isblank(A2:A),,weeknum(A2:A)))
G2=if(F2<>F1,sum(iferror(filter(B$2:B,F$2:F=F2),0)),0)
And then copy G2 through G3:G.
Related
I want to count orders for each month by incrementing each order and resetting them for the next month in a dynamic fashion, like this.
I tried COUNTIF function to count the range of MONTH but the out put is the count if all the range, Take a look at the Sheet.
As per your provided sheet try below formula-
=Arrayformula(IF(D2:D="",,COUNTIFS(D2:D, D2:D, ROW(D2:D), "<="&ROW(D2:D))))
Actually you do not need helping Month column. You can achieve your desired result directly using below formula.
=Arrayformula(IF(B2:B="",,COUNTIFS(Month(B2:B), Month(B2:B), ROW(B2:B), "<="&ROW(B2:B))))
I have a problem to use sumproduct with array formula in Google Sheet which seems workable in Excel. The formula returns only 1st array value (E8*F8) which what I have to do is to get total sales price from everyday.
Below is the formula I used:
=SUMPRODUCT(ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2-1)),ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2)))
Below is the table view:
My Spread Sheet Link
Try this formula
=SUMPRODUCT(ARRAYFORMULA(FILTER(E8:J8, ISEVEN(COLUMN(E8:J8)))), ARRAYFORMULA(FILTER(E8:J8, ISODD(COLUMN(E8:J8)))))
Or even simpler
=SUMPRODUCT({E8,G8,I8}, {F8,H8,J8})
I have data in the below format:
The "Date" Column is a sequence of dates generated using the formula:
=sequence(datedif(TODAY(),MAX(D2:D),"D")+2,1,TODAY(),Date(0,1,0))
The "Avg. Mnthly Hrs" is calculated against each Date value as below:
=SUMIF(D:D,">="&E2,C:C)
The issue here is, whenever I have a new Project, where the "Exp. Project End Date" is let's say 5/31/2045, the Date column is extended automatically using the sequence formula and generates values in days until that day but the "Avg. Mnthly Hrs" formula doesn't calculate the new values (like in Array Formula).
The ArrayFormula doesn't work with SumIF formula. Is there any similar alternative so that the "Avg. Monthly Hrs" formula extends automatically for new values in Date column.
In F2, try
=arrayformula(if(E2:E="",,SUMIF(D:D,">="&E2:E,C:C)))
I have a sheet with a timeline that shows a month per row in column A and an amount in USD next to that month in column B.
I want to be able to specify amounts in column G with a start and end date for that amount in columns E and F.
What I am trying to achieve is that the values in column B are automatically calculated by looking at the start and end dates specified in columns E and F and then taking the corresponding value from column G if the date in column A falls in between the date range specified in E and F.
I have found many suggestions for similar problems online but wasn't able to get any of them to work for my specific case. Any help is very welcome
You could do it as an array formula like this:
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("`E3:E"&count(E3:E)+2)),"YYMM"))*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))*transpose(indirect("G3:G"&count(G3:G)+2)),(INDIRECT("G3:G"&count(G3:G)+2)+2)^0))
The idea is to develop a 2D array where the rows are the months and the columns are the amounts for matching time periods. Then use the standard Mmult method to get the row totals of the array.
Using indirect for the ranges makes the formula longer but using full-column references would be slow as it would result in a nearly 1000 X 1000 array for a default-sized sheet.
EDIT 1
Or shorter
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("E3:E"&count(E3:E)+2)),"YYMM"))
*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))
,INDIRECT("G3:G"&count(G3:G)+2)))
because you can combine the row totals step with multiplication by column G.
EDIT 2
Alternatively you could just employ a much simpler pull-down formula using SUMIFS:
=ArrayFormula(sumifs(G$3:G,eomonth(E$3:E,-1)+1,"<="&A2,F$3:F,">="&A2))
This uses Eomonth to change all the start dates to the first of the month so they can be compared to the dates in column A correctly. The formula still has to be entered as an array formula because of the Eomonth calculation.
Note
The equivalent pull-down formula to the original array formulas above would be
=ArrayFormula(sumifs(G$3:G,text(E$3:E,"YYMM"),"<="&text(A2,"YYMM"),text(F$3:F,"YYMM"),">="&text(A2,"YYMM")))
but this gives zero for all rows - the reason for this is not obvious to me at time of writing.
I have a google spreadsheet in which I enter daily income and expenses:
On another sheet, I am trying to calculate the monthly income and expenses for every month:
I am using this formula to calculate the monthly income ('s1' is the daily sheet):
=ARRAYFORMULA(SUM(FILTER(s1!B2:B; MONTH(s1!A2:A)=MONTH(INDIRECT("A" & ROW())))))
but it does work for the whole column.
Is there any way to make the arrayformula work with the indirect and row functions?
I think this would work as a SUMIF instead - try:
=ArrayFormula(IF(A2:A="",,SUMIF(MONTH(s1!A2:A),MONTH(A2:A),s1!B2:B)))