Averaging data over three years based on date of a weekday or weekend

nmusoke17

New Member
Joined
Jun 5, 2024
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
I have data based on date and day over three years. however, I want to do an average of the data for a particular date over the three years and if that date is a weekday for all three years it averages for all the years and if not, it only averages for the number of times that date falls on a weekday for those previous three years. What excel formula can I use to do that automatically?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Maybe this:

Cell Formulas
RangeFormula
E2:E8E2=AVERAGE(FILTER(B2:B22,(MONTH(D2)=MONTH(A2:A22))*(DAY(D2)=DAY(A2:A22))*(WEEKDAY(A2:A22,2)<6)))
D3:D8,A3:A8D3=D2+1
A9:A22A9=EDATE(A2,-12)


Hope it helps. And welcome to the forum.
 
Upvote 0
I have tried using that formula but Excel keeps giving me a message that “formula is invalid. It may be because Ms excel 2019 doesn’t have “FILTER” as a function, is it doesn’t recogise it in the formula. What could be the workaround.

Thanks
 
Upvote 0
Mmm. Yes, I'll work on something. But, usually when a function is not available it is a #NAME error not a formula invalid error. Have you tried pasting the entire mini sheet in a brand new workbook or worksheet? If it works like that it should be in your version.

Also, when I was working on the formula I looked at the contextual help of the filter in a formula dialog box and it says it is in 2019:

(Also please paste the formula you used, as you may have a typo)
1717657643254.png
 
Upvote 0
Here it is as a CSE (CNTL SHFT ENTR) Array formula:

Cell Formulas
RangeFormula
E2:E8E2=AVERAGE(FILTER(B2:B22,(MONTH(D2)=MONTH(A2:A22))*(DAY(D2)=DAY(A2:A22))*(WEEKDAY(A2:A22,2)<6)))
D3:D8,A3:A8D3=D2+1
G2:G8G2=SUM((MONTH(D2)=MONTH(A2:A22))*(DAY(D2)=DAY(A2:A22))*(WEEKDAY(A2:A22,2)<6)*(B2:B22))/ SUM((MONTH(D2)=MONTH(A2:A22))*(DAY(D2)=DAY(A2:A22))*(WEEKDAY(A2:A22,2)<6))
A9:A22A9=EDATE(A2,-12)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Mmm. Yes, I'll work on something. But, usually when a function is not available it is a #NAME error not a formula invalid error. Have you tried pasting the entire mini sheet in a brand new workbook or worksheet? If it works like that it should be in your version.

Also, when I was working on the formula I looked at the contextual help of the filter in a formula dialog box and it says it is in 2019:

(Also please paste the formula you used, as you may have a typo)
View attachment 112361
I believe that page is wrong. FILTER is available starting from version 2021.
 
Upvote 0
I believe that page is wrong. FILTER is available starting from version 2021.
Thanks. Good to know.

But, why did it generate a FORMULA ERROR instead of a #NAME error?

But, I did provide an alternate solution.
 
Upvote 0
Thanks. Good to know.

But, why did it generate a FORMULA ERROR instead of a #NAME error?

But, I did provide an alternate solution.
It might just be how Excel handled errors in 2019. I don't recall.
Yes, I've noticed. Just wanted to clarify the confusion above.
 
Upvote 0
Thanks a lot for the support. I have tried using the second formula you shared, but it also doesn't seem to work as expected. let me share with you some datasets and see how can help out.
01/07/2020​
282,691
02/07/2020​
276,428
03/07/2020
482,806
04/07/2020
531,723
05/07/2020
780,749
06/07/2020
395,985
07/07/2020
232,047
08/07/2020
948,012
09/07/2020
384,201
10/07/2020
527,073
 
Upvote 0
Thanks a lot for the support. I have tried using the second formula you shared, but it also doesn't seem to work as expected. let me share with you some datasets and see how can help out.
01/07/2020​
282,691
02/07/2020​
276,428
03/07/2020
482,806
04/07/2020
531,723
05/07/2020
780,749
06/07/2020
395,985
07/07/2020
232,047
08/07/2020
948,012
09/07/2020
384,201
10/07/2020
527,073
showing us the formula you used would be a better way for us to help you. And not telling us the exact error message is no help at all.

But just looking at the table... it seems you have dates that are text and not dates. Be sure all the first column are dates (select the entire range of first column and format as a number. If the values do not change to numbers you have text values not date values). The same for the second column, except try to add decimals.... if they remain left justified or do not display .00, .0, etc. then they are also text and not numbers..

And did you paste the solutions i offereed into a fresh workbook or worksheet???? What happened?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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