I have a Google Sheets budget spreadsheet that uses SUMIF to calculate bills due between certain days of the month. I have 2 column, E and F, that have the day of the month when the bill is due and the amount due. I'm trying to figure out how to SUMIF the value if the corresponding dates fall between a specified range of days of the month.
I'm assuming this will be a combination of SUMIF and VLOOKUP, but I have no idea how to put this formula together.
I'm expecting the calculated fields to do this: if the date range is from the 4th through the 10th, add up all of the bills due from the 4th through the 10th. Then, for the 11th through 16th, add all the bills due from the 10th through the 16th, etc.
You want to calculate the values in a range where there are two criteria.
Use SUMIFS
sum range = $K$2:$K$24 (note: absolute reference)
criteria range = $I$2:$I$24 (again, absolute reference)
criteria#1 = ">="&B4 - greater than or equal to the start value; note the operators are in quotations and the "START" cell address is added with a "&".
criteria#2 = "<="&C4 - less than or equal to the end value; note the operators are in quotations and the "END" cell address is added with a "&".
=sumifs($K$2:$K$24,$I$2:$I$24,">="&B4,$I$2:$I$24,"<="&C4)
Related
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'm using Google Sheets to create a financial record.
What i'm trying to do is create a formula that takes 3 columns in my data range in to consideration. The three columns are a date, a word and a number.
The first part of the formula will check that the date is the current month (not within 30 days, but the current month). The second part will check whether the word "Yes" is present in the second column, and if those two are true, then it will take the average of column 3 for all other rows that are also completely true.
Column C is Date
Column W is Word
Column Y is Number
I've tried a number of methods, the first one was to use a average IF function, where i used a filter to check the dates, and then the word Yes in the criterion. This resulted in a number, although it was incorrect, as the formula first gathered the sequence of Yes and No's, once it had the sequence it applied it to the third column but it started from my earliest entry (not my current month). This code is below.
So alternatively i tried another method. Which was using a query function. Although i'm stuck on how to compare the month of a date to the current today() month. This gives no results, even though the current month is 8, and the dates month is also 8. I've also inputted this code below.
=AVERAGEIF(filter(W8:W800,month(C8:C800)=month(today())),"Yes",Y8:Y800)
=query(query(A8:Z800,"select month(C)+1, W, Y where W ='Yes'",0),"select Col1, Col3, Col4 where Col1 ='"&month(today())&"'",1)
results explained in background
Your nesting is a bit off. If you're using FILTER, use plain AVERAGE instead of AVERAGEIF, and make sure you're grabbing the right column to aggregate. Lastly, don't forget to wrap in IFERROR to handle your empty case.
=IFERROR(AVERAGE(FILTER(Y8:Y800, MONTH(C8:C800)=MONTH(TODAY()), W8:W800="Yes")), 0)
if you have multiple criterions you need to use AVERAGEIFS instead of AVERAGEIF
=ARRAYFORMULA(AVERAGEIFS(C2:C, B2:B, "yes", MONTH(A2:A), MONTH(TODAY())))
I have a spreadsheet which tracks weekly meeting attendance. I need to return the number of individuals who attended at least one meeting in the month, not the sum total of weekly meeting attendees. In other words, if a person attended 4 meetings in the month, the count is incremented by 1, not 4.
Names are listed in Column A, and the weeks in the month are listed in columns B-F (e.g. B2 is "Sep 2"; C2 is "Sep 9"; "D2 is "Sep 16", and so on.) When a person attends a meeting, the corresponding cell receives an "X".
So far, the only method I know I can use to return the number of unique or distinct meeting attendees is to first use a set of formulas in one column (H) to return whether an "X" is found in the corresponding rows, and then a second formula that references the range (in column H) containing the first set of formulas to return the number of TRUE results.
What I'm trying to do is use an ArrayFormula or something similar to give me the final number in just one shot. I'm currently using a COUNTIF function on values in a column range while the rows in that very range are populated using COUNTA functions.
How can I use just one formula to return the attendance count - not depending on that intermediary step/range in column H?
I can't seem to get an array formula to work correctly, and I haven't been able to find similar answers despite hours of searching. Apologies if there are similar questions already posted (I couldn't find one asking quite the same question as mine). Here's my best attempt so far:
=ArrayFormula(COUNTIF(COUNTA(B3:F17) > 0,TRUE)) ...which returns 1.
Here is an example spreadsheet with sample data.
In I22 I entered this formula
=countif(ArrayFormula(countif(if(B3:F17="X", row(B3:B17)), row(B3:B17))), ">0")
the formulas in H3:H17 are not used in this formula.
See if that works?
I'm trying to have a function in Google Sheets that adds up values from a range if the were entered on a Monday. This is what I have right now, but it adds up to 0 all the time:
=sumif(B6:B20, WEEKDAY(2),C7)
Can someone tell me how to determine what day of the week a number cell was added on, and then add up all the numbers added on that day so I can put the sum in a different cell? (For example, the numbers in the range were added on various days of the week, and I want to add up all the numbers that were added on Monday)
Assuming column B is the column to sum and column C has the dates try:
=sumproduct(weekday(C2:C) = 2,B2:B)
I'm sure this is doable and I'm just not finding the solution in the documentation, so big thanks in advance for your help. I want to calculate sales growth month over month.
For example, I'm posting this question on 10/22/2014. Calculating sales thus far for this month is easy, but I also need to know what sales were for the first 22 days of LAST month.
I already have a column containing the values for each day this month, and another column containing the values for each day last month. All I need to do is a way to sum the values for the first 22 days of last month.
Column AH = A list of the dates for last month: 9/1/2014, 9/2/2014...
Column AI = A helper column containing only the DAY of the month of the value in Column AH: 1,2,3,4...
$AJ35 = The day of today's date =DAY(TODAY())
Column AN = The numbers I want to (conditionally) sum
Why won't this formula work?
=SUMIF(AI1:AI34,"<=$AJ35",AN1:AN34)
It calculates a sum of 0.
If I take out the comparison ("<=$AJ35") and manually insert a number, it works fine:
=SUMIF(AI1:AI34,"<=22",AN1:AN34) returns a value of 362, as expected.
That is because you have put a cell reference inside a string (surrounded by double quotes)
which means that google is trying to compare against a literal string "$AJ35"
you have to concatenate the cell reference and the operator like so:
=SUMIF(AI1:AI34,"<=" & $AJ35,AN1:AN34)