Excel Formula to sum value if date falls in particular month - excel

I am trying to make a table in excel which calculate sum of some values if a date falls in a particular month.
On the column A are dates, on column B some values, on column E are only listed numbers from 1 to 12 and in column F there are cells with =SUM(IF(MONTH($A$1:$A$10)=E11; $B$1:$B$10; 0)) formula.
I dont really know why on F9 the value is 0 even if checked with the debuger (F9 key) and saw that the result of the foruma is 22, which is the expected value. Also, I dont know why on F11 and F12 I receive an error: A value used in the formula is of the wrong data type
What can I do to solve this problems? Thank you

I solve the problem. I surounded the foruma with curly brackets ( { } ) and now works

For versatility and perhaps speed in a large spreadsheet I think you might consider a PivotTable. So label your two columns (say Date and Value), insert a PT with Date for ROWS and Sum of Value for VALUES, then Group..., Years (avoids summation of the same month but different year) and Months.

Related

Average of sum of column values

I have a table with 2 columns : dates (1st of the month) and values. Each date can appear an unknown number of time. I am trying to find a formula that would make a yearly average of the sum of the value for each month.
I can easily make several sumproducts to have the sum of values for each month and then average but I would prefer to limit the size of the formula.
Does anyone has an idea on how to do that, or if that's even possible?
I assume that dates are in A column and values in B column.
The easiest way would be:
1) In third column (C), store the integers indicating the month. You will get this result by simple =MONTH() Excel function, ex.: =MONTH(A1), etc.
2) To get the average from particular month, say September (9th month), you need to enter the formula:
= SUMIF(C:C,"=9",B:B)/COUNTIF(C:C,"=9")
If you want the average for different month, you just change the 9 in SUMIF and COUNTIF.
You could make a pivot table, then drag the date in row field and values in value field. Then change the field setting of the values to 'average'.

Excel Formula for averaging by weekday

I'm trying to summarize 2 years worth of data quickly by month. What I want to do is to average only the values from Monday to Friday for each month.
If you change column b to be a calculated day of week field like so:
=TEXT(B2, "ddd")
And you insert a new column c field that is calculated month like so:
=TEXT(B2, "mmm")
You can then use an array formula to solve your problem. You might need to modify the formula slight based upon your data but the follow formula should work.
=AVERAGE(IF((C:C<>"Sat")*(C:C<>"Sun")*(D:D="May"),E:E))
Keep in mind because this is an array formula you have to hit Ctrl+Shirt+Enter on a PC or Command+Return on a Mac. Basically what it is saying is that if column C is not Sat and not Sun and column D is May, then average the value in column E.
Not too difficult.
Try this:
= SUMPRODUCT((WEEKDAY(B2:B99,2)<6)+0,D2:D99)/SUMPRODUCT((WEEKDAY(B2:B99,2)<6)+0)
I have the last row as 99 but you can just change that 99 to whatever your last row is that you need.
EDIT:
Just noticed you said "by month". The formula above will take the average column D where column B is a weekday. To modify for a specific month, the formula just needs to be slightly modified to account for the month also. See below, this shows how to do it for the month of May. (Month = 5) I broke it up into two lines so it is easier to read.
= SUMPRODUCT((WEEKDAY(B2:B99,2)<6)+0,(MONTH(B2:B99)=5)+0,D2:D99)
/SUMPRODUCT((WEEKDAY(B2:B99,2)<6)+0,(MONTH(B2:B99)=5)+0)
Similar to peter's answer, use the following formula in K2:
=SUMPRODUCT((WEEKDAY(B:B,1)>1)*(WEEKDAY(B:B)<7)*(MONTH(B:B)=MONTH(DATEVALUE("01-"&$J$2&"-2017")))*(D:D))/SUMPRODUCT((WEEKDAY(B:B,1)>1)*(WEEKDAY(B:B)<7)*(MONTH(B:B)=MONTH(DATEVALUE("01-"&$J$2&"-2017"))))
Warnings: Despite not being a CSE /ARRAY formula, SUMPRODUCT performs array like calculations within its brackets. As such, full column references like B:B should not be used. Instead B:B should be adjusted to match the needs of your data. In this case it should be B2:B22.
In the sumproduct formula above, the * are acting like AND statements. It evaluates a logical comparison to either true or false. If true or false is then put through a math operation, true values become 1 and false values become 0. Therefore only rows where everything is true are counted. The last step of the sumproduct is to sum all the results. Therefore all rows containing a false will become zero and not affect the summation.
The tid bit in the formula that refers to J2 basically converts what is assumed to be a month in text to a date that can be recognized by excel which then converts it to a numeric value which can then be compared to the month in your date list. Now the only caveat here is that its every month of year irregardless of the year. If you need a month from a specific year you will need the formula adjusted.

How do I write an excel formula to count the number of a value in one column based off of a date in another column?

I have a worksheet and I'm trying to do a simple Count function, probably a countif but I'm unsure how to go about writing the formula.
I have two columns that I'd like to use for this formula.
Column N - I would like to filter for the Criteria of "C" or anytime a cell has a value of C
Column 0 - This column has dates filled in (short date format).
I would like to get a count of every C for each month, as simple as that.
In this example I filtered the date for May of 2017 and filtered for C under the Check column. We can see that there are 12 instances of C showing in the month of May 2017.
Does anyone know how to structure a formula that I would be able to Count the Number of C's for every month into the foreseeable future?
I figured out how to count the total present in a date range but unsure of how to add the date range plus Column N (Check) every time "C" is present in the cell.
=SUMPRODUCT((O:O>=DATEVALUE("5/1/2017"))*(O:O<=DATEVALUE("5/31/2017")))
Try this
=COUNTIFS(O1:O100,">="&A1,O1:O100,"<"&B1,N1:N100,"C")
Where A1 has the start date and B1 has the end date for that month. You can use DATEVALUE() instead of A1 and B1. Change as applicable
Screenshot
If you want to use SUMPRODUCT then see this
=SUMPRODUCT((O:O>=DATEVALUE("1/5/2017"))*(O:O<=DATEVALUE("30/5/2017"))*(N:N="C"))
In another column (lets say 'P' for example) I would insert a formula to give you the month number =Month(P7) - this will return 5 for May.
I would then use COUNTIFS (Like COUNTIF but it uses multiple criteria) to count where column N contains 'C' and column 'P' contains '5'.
=COUNTIFS(N:N,"C",P:P,5)
Try this....you need to select the entire Column B and named the column as 'Date'.enter image description here

CountIf not counting values derived from formula

I couldn't find a matching answer already but happy to be redirected!
My issue is with countifs across two worksheets but I can replicate it in a smaller environment.
I have three columns of data (A-C): -
Column D has the formula =IF(A2="Closed",C2-B2,0).
That bit works, I now need to count how many took X number of days to close: -
Column G has the formula =COUNTIFS(A2:A11,"Closed",D2:D11,F2)
Looking at the pictures 41 and 49 should have a count of 1 right? What have I done wrong? All cells are formated as numbers.
Your formula in column G uses an absolute comparison to the value in column F.
The problem is that none of your values exactly match that value.
The duration column is formatted to show a value rounded to a day, but the underlying value is not the same as what is showing in the formatted cell.
Therefore, the formula in column G needs to factor in a range of values like this:
=COUNTIFS($A$2:$A$11,"Closed",$D$2:$D$11,">="&F2,$D$2:$D$11,"<"&F3)
In words: count all the cells where column A shows "Closed" and where the value in column D is between the value in F2 and the value in F3.
You will need to add an extra value in column F for anything above your biggest number in column F.
Check you output in Column D. It must be having decimals. If that is the case, you need to round the formulas in column D using ROUND formula.
=ROUND(IF(A2="Closed",C2-B2,0),0)
Rows 4 and 7 have status as "Open" and hence won't be counted by Countifs, i. e. change value of cells A4 and A7 to "Closed" to see updated results.
Also, fix your range $A$2:$A$11, etc. when using Countifs

A formula in Excel to count the number of rows where there is a date in column 'K' but column 'N' is blank?

I am a little rusty to say the least and in Excel I would like to create a formula that counts the number of cases that have been closed without a certain stage taking place.
So, the formula would need to count the number of rows where there is a date in column k, but no date in column n (the cell is blank). Any help would be appreciated. I have had a go with COUNTIFS and SUMPRODUCT but I'm not getting anywhere.
Try this
=COUNTIFS(K:K,">0",N:N,"")
that's counting rows where K is greater than zero but N is blank [""]
If you can use another column try this formula, for every row of the column:
=IF(K1>0,1,0)*IF(N1="";1;0)
then you have to sum column values.
Instead of K1>0 you can use two cell for date so you can count cells within a range of date.
For a start try something like:
=SUMPRODUCT((K1:K100<>"")*(N1:N100=""))

Resources