How to Divide If Data Exists?

kubrendan2

New Member
Joined
Nov 13, 2014
Messages
4
I have a spreadsheet where I track data each month, which produces one number for the month. I'd like to have an average of each month without having to manually change the number of months in which data exists. Is there a way to easily create a formula that will calculate the average after a month is over (basically, dividing by 1 after February 1, dividing by 2 after March 1, etc.

This is all that is there now, since it's still January. Each of the zeros are for the months that haven't happened yet.

21900000000000

Thanks!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I'm confused with your set up. Is this expected results or the data you want to have averaged?
Can you post some dummy data for 3 or 4 months?

Do you want something like this?:

Book2
ABCDEFGHIJKLM
1ytd avg
22190000000000219
3
4
52192442572230000000235.75
Sheet3
Cell Formulas
RangeFormula
M2,M5M2=AVERAGEIFS(A2:K2,A2:K2,">"&0)
 
Upvote 0
Thank you! You have the data idea correct; except I'd prefer it to not calculate into the average until the month is over (since one month with 219 and the next with 4 wouldn't look good). I was trying to put =today() in one cell and then try to set the denominator based on if that cell < 02/01/2024, then = 0, if < 03/01/2024, then = 1, and so on, but I was not getting the syntax correct, if that is even a possible way to do it.
 
Upvote 0
Okay, I have hard coded a date in this sample, you can insert a Today Function in there...
Cell Formulas
RangeFormula
C1:M2C1=EDATE(B1,1)
N3N3=SUM(($B$3:$M$3)* ($B$2:$M$2<EOMONTH(DATE(2023,2,5),-1)+1))
N6N6=SUM(($B6:$M6)*($B$2:$M$2<EOMONTH(DATE(2023,4,5),-1)+1))/ SUM(--($B$2:$M$2<EOMONTH(DATE(2023,4,5),-1)+1))

 
Upvote 0
Maybe another option.
Enter the last day of each month in the date range. You can format this as just month or month - year, etc (or any way you want).
Then use the AVERAGEIF function.
For the example I started with dates in 2023 just to have some data.

Book1
ABCDEFGHIJ
1Date10/31/202311/30/202312/31/20231/31/20242/29/20243/31/20244/30/20245/31/20246/30/2024
2245600000
3
4Average3.6667
Sheet1
Cell Formulas
RangeFormula
B4B4=AVERAGEIF($B$1:$J$1,"<="&TODAY(),$B$2:$J$2)
 
Upvote 0
Solution
I'm sure that first way worked, but it was beyond my level of ability to make it work. That second idea worked great, other than it gives me a division by 0 error now, since the first month isn't over. i forget how to make that just be blank instead of displaying the error?

Thank you both so much for taking the time to help!!
 
Upvote 0
This should stop the error and show a blank.
=IFERROR(AVERAGEIF($B$1:$J$1,"<="&TODAY(),$B$2:$J$2),"")
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,270
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top