Counting back from today but ignoring some cells

Bren4242

New Member
Joined
Jan 25, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi All,
I input a range of data for each day of the year. I need to calculate the average output over the last 30 "production days" and just cannot get it right.

1) I can't take the usual average as some days are not production days, so I need to exclude those days from the calculation.
2) I need the average over the last 30 production days, so those non-production days should be ignored in the 30-day count
3) There are some days where production is also zero, but it's still a production day, so that day and the zero has to be included in the average.

Some examples below:
Date (dd/mm/yyyy)Production day?Production
01/01/2022Yes0
02/01/2022No0
03/01/2022No0
...inbetween dates...assume all "Yes"...assume all zero
30/1/2022Yes0
31/1/2022Yes7
01/02/2022Yes8

for 01/02/2022: Average is calculated for the date range 01/01/2022-01/02/2022, 32 days but two of those are non-production days. Average = (7+8)/30 = 0.5
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
@Bren4242 Welcome.
Are you wanting the 30 day average on a daily basis?
Does like below help? It utilisesa 'Helper' column that you could hide if you wish.

Book1
ABCDE
1DateProd DayProd30 Day AvHelper
201/01/2022Yes001
302/01/2022No00 
403/01/2022No00 
504/01/2022Yes002
605/01/2022Yes003
706/01/2022Yes004
807/01/2022Yes005
908/01/2022Yes006
2928/01/2022Yes0026
3029/01/2022Yes0027
3130/01/2022Yes0028
3231/01/2022Yes70.2429
3301/02/2022Yes80.530
3402/02/2022No00 
3503/02/2022No00 
3604/02/2022Yes15131
3705/02/2022No00 
3806/02/2022Yes0132
3907/02/2022Yes0133
4008/02/2022Yes0134
41
Sheet4
Cell Formulas
RangeFormula
D29:D40,D2:D9D2=IFERROR(AVERAGEIFS(C$2:C2,B$2:B2,"Yes",E$2:E2,"<"&E2+1,E$2:E2,">"&E2-30),L1)
E29:E40,E2:E9E2=IF(B2="Yes",COUNTIF(B$2:B2,"Yes"),"")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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