Average of sum of column values - excel

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'.

Related

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 to count number of records active in all dates in Excel? [duplicate]

I have a sheet of trainings in excel that are organized by date and I am trying to do a monthly statistics report. So, I want to count, through an excel formula, the number of trainings that were done in the month that is specified in the header of the statistics column. The header has the month in number format and the dates in the training sheet are in 01/23/2015 format. For example, if the header of the stat column was "1" I would want to count all the trainings that were done in January 2015. Any help with this issue would be greatly appreciated!
If the dates of the exercises are in format mm/dd/yyyy I would suggest making a new column (in column B) for the month and a new column (in column C) for the year
The formula for extracting months from a column is
=TEXT(A1,"mmmm")
The formula for extracting years is
=YEAR(A1)
Add these formulas to columns B and C and now you can use the filters in excel to show only training exercises from the year and month you want. I think the filters are the best way to view the exercises you want and it is easy to get counts from these looking at the number of rows in the filter table.
However, if you want to show the number of exercises that occurred in a certain month/year you can write an if statement that will give a value of 1 if your criteria is matched and a value of 0 if the criteria is not matched. This will look something like this:
=IF(B1="January",1,0)
This will check if the month in column B is "January", then return the value 1 if it is "January". If it is not January, it will return 0.
To see the number of times a year appears use:
=IF(C1=2015,1,0)
This will check if the year in column C is 2015, than return the value 1. If it is not January, return 0.
Add these formulas to columns D and E.
Then sum the values in this column
=SUM(D1:D1000)
for month, and
=SUM(E1:E1000)
for year, and you will get the number of reports that matches your criteria. This is one way you can use Excel formulas to obtain the number of exercises in a certain month or year. If you have more than 1000 reports just change the number to 10,000 or more.
Hope this helps!
With the "header of the stat column" as A1 and the training dates in A2:A999 you could use,
=countifs(a2:index(a:a, match(1e99, a:a)), ">="&date(2015, a1, 1), a2:index(a:a, match(1e99, a:a)), "<"&edate(date(2015, a1, 1), 1))

Count all records from certain month in excel

I have a sheet of trainings in excel that are organized by date and I am trying to do a monthly statistics report. So, I want to count, through an excel formula, the number of trainings that were done in the month that is specified in the header of the statistics column. The header has the month in number format and the dates in the training sheet are in 01/23/2015 format. For example, if the header of the stat column was "1" I would want to count all the trainings that were done in January 2015. Any help with this issue would be greatly appreciated!
If the dates of the exercises are in format mm/dd/yyyy I would suggest making a new column (in column B) for the month and a new column (in column C) for the year
The formula for extracting months from a column is
=TEXT(A1,"mmmm")
The formula for extracting years is
=YEAR(A1)
Add these formulas to columns B and C and now you can use the filters in excel to show only training exercises from the year and month you want. I think the filters are the best way to view the exercises you want and it is easy to get counts from these looking at the number of rows in the filter table.
However, if you want to show the number of exercises that occurred in a certain month/year you can write an if statement that will give a value of 1 if your criteria is matched and a value of 0 if the criteria is not matched. This will look something like this:
=IF(B1="January",1,0)
This will check if the month in column B is "January", then return the value 1 if it is "January". If it is not January, it will return 0.
To see the number of times a year appears use:
=IF(C1=2015,1,0)
This will check if the year in column C is 2015, than return the value 1. If it is not January, return 0.
Add these formulas to columns D and E.
Then sum the values in this column
=SUM(D1:D1000)
for month, and
=SUM(E1:E1000)
for year, and you will get the number of reports that matches your criteria. This is one way you can use Excel formulas to obtain the number of exercises in a certain month or year. If you have more than 1000 reports just change the number to 10,000 or more.
Hope this helps!
With the "header of the stat column" as A1 and the training dates in A2:A999 you could use,
=countifs(a2:index(a:a, match(1e99, a:a)), ">="&date(2015, a1, 1), a2:index(a:a, match(1e99, a:a)), "<"&edate(date(2015, a1, 1), 1))

Excel Formula to sum value if date falls in particular month

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.

SUM a range of rows by looking up by a separate column

I have a spreadsheet. It has a timestamp in Column A and a dollar value in Column C.
I have another sheet that provides calculated values of the whole sheet, but I am also trying to provide a way for a user to type in a date as the start date cutoff. "Give me the number of entries since 10/1/2012" and "Give me the sum of all dollar values since 10/1/2012".
The count was easy, using a COUNTIF, however, I'm struggling to come up with the formula to give the dollar sum, based on the date cutoff. Since Date is in column A and dollars in column C.
Thanks!
Try SUMIF
=SUMIF(A:A,">="&D2,C:C)
where cutoff date is in D2

Resources