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)))
Related
I'm trying to use a formula in Google Sheets to use the date values of cells in Sheet1 (a27 and b27) as the Date references for the date range in the coutifs formula below.
=countifs('Sheet2'!$C:$C,">=01/10/2023", 'Sheet2'!$C:$C,"<=01/17/2023",'Sheet2'!$D:$D,"Apples")
This initial formula works fine, where I am trying to count how many instances of "apples" occurred in a specific date range on Sheet 2 (1/10/2023-1/17/2023).
As you can see, the dates on Sheet 2 are in column C, and the instance of "Apples" would be in column D.
However, I am trying to find a way to pull the data from Sheet2 to Sheet1 using date references in 2 cells in Sheet1. 'Sheet1'!a27 has the date value for 1/10/2023, and 'Sheet1'!b27 has the value for 1/17/2023.
I would like to be able to use the Sheet1 a27/b27 placeholders instead of manually going in and entering dates into the formula.
I have tried the string below, hoping it would pull the date values from Sheet1 a27&b27 automatically to be the date of reference for the countifs formula from Sheet2.
While it is not causing an "error", it is not pulling any numbers at all.
=countifs('Sheet2'!$C:$C,">='Sheet1'!a27", 'Sheet2'!$C:$C,"<='Sheet1'!b27",'Sheet2'!$D:$D,"Apples")
Please note that Sheet2 column C and Sheet1 columns b&c already have the number formats set to "date".
try:
=COUNTIFS(Sheet2!C:C, ">="&Sheet1!A27,
Sheet2!C:C, "<="&Sheet1!B27, Sheet2!D:D, "Apples")
In the picture M3 is today's date. Is there a formula that will automatically pull data from M8 (same column) since M3's date matches today and place it in another, unrelated cell? The closest I can get is a where function with a query, but I could not get it to work.
use:
=INDIRECT(ADDRESS(8, MATCH(TODAY(), 3:3, 0)))
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 am using an array formula and IMPORTRANGE to import and combine a date column and time column from another sheet:
=ARRAYFORMULA(IMPORTRANGE(BG1, "FORM-SORT!V:V") & CHAR(10) & (IMPORTRANGE(BG1, "FORM-SORT!W:W")))
The first range is my date column and the second is my time column. The data is importing and combining properly, however neither the date nor time is formatting correctly, they are displaying integer values and will not respond to any number formatting options.
Please try:
=ARRAYFORMULA(text(IMPORTRANGE(BG1,"FORM-SORT!V:V"),"dd-mm-yy")&CHAR(10)&TEXT(IMPORTRANGE(BG1,"FORM-SORT!W:W"),"hh:mm"))
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.