Formula to average all Monday values in a calendar month excluding a holiday

pbgexcel

New Member
Joined
Jan 2, 2018
Messages
26
I have a vertical list consisting of every single day in the year and a corresponding price. I'm looking to use AVERAGEIFS() to average only the Monday values in a given month excluding any holidays, the dates for which I have listed elsewhere for reference.

Right now I'm trying to use MONTH()=1 AND WEEKDAY()=1 to specify only the Mondays in January, but to no avail. I also want to exclude 1/1/2018, as New Year's is a holiday, as I have noted in another cell, 'C1', for referencing in the formula. Any ideas how to go about this?

Thanks for your help!
[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Value[/TD]
[/TR]
[TR]
[TD]1/1/2018[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]1/2/2018[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]1/3/2018[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]1/4/2018[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]1/5/2018[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]1/6/2018[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]1/7/2018...[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]12/30/2018[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]12/31/2018[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I'm currently working with this, but Excel does not even accept it as a formula:

=AVERAGEIFS(DD4:DD37,DC4:DC37,MONTH()=1,DC4:DC37,WEEKDAY()=1)

DD4:DD37 contains the values to average together
DC4:DC37 contains the corresponding dates for these values

I try to check the month and day of week of these dates as average criteria.
 
Upvote 0

Excel 2010
ABCDE
1Mon 01-Jan-1810FALSE20
2Tue 02-Jan-1820FALSE
3Wed 03-Jan-1810FALSE
4Thu 04-Jan-1820FALSE
5Fri 05-Jan-1810FALSE
6Sat 06-Jan-1820FALSE
7Sun 07-Jan-1810FALSE
8Mon 08-Jan-1820TRUE
9Tue 09-Jan-1810FALSE
2a
Cell Formulas
RangeFormula
D1=AND(WEEKDAY(A1,1)=2,COUNTIF(Hol,A1)=0)
E1=AVERAGEIF(D1:D9,TRUE,B1:B9)
Named Ranges
NameRefers ToCells
Hol='2a'!$J$1


The holidays are in the range named "Hol".
This uses a helper column.
 
Upvote 0
without a helper column try

=SUMPRODUCT(--(TEXT(A1:A9,"ddd")="Mon"),--(A1:A9<>Hol),(B1:B9))/SUMPRODUCT(--(TEXT(A1:A9,"ddd")="Mon"),--(A1:A9<>Hol))
 
Upvote 1
If you require the calculation by month, you can expand the formulas

=AND(WEEKDAY(A1,1)=2,COUNTIF(Hol,A1)=0,MONTH(A1)=1)

=SUMPRODUCT(--(TEXT(A1:A14,"ddd")="Mon"),--(A1:A14<>Hol),--(MONTH(A1:A14)=1),(B1:B14))/SUMPRODUCT(--(TEXT(A1:A14,"ddd")="Mon"),--(A1:A14<>Hol),--(MONTH(A1:A14)=1))
 
Upvote 0

Excel 2010
ABCFG
1Mon 01-Jan-1810Mon011852.5
2Tue 02-Jan-1820
3Wed 03-Jan-1810
4Thu 04-Jan-1820
5Fri 05-Jan-1810
6Sat 06-Jan-1820
7Sun 07-Jan-1810
8Mon 08-Jan-1820
9Tue 09-Jan-1810
10Mon 15-Jan-1830
11Tue 16-Jan-1840
12Mon 22-Jan-1850
13Mon 29-Jan-18110
14Mon 05-Feb-1870
2a
Cell Formulas
RangeFormula
G1=SUMPRODUCT(--(TEXT(A1:A14,"dddmmyy")=F1),--(A1:A14<>Hol),(B1:B14))/SUMPRODUCT(--(TEXT(A1:A14,"dddmmyy")=F1),--(A1:A14<>Hol))
Named Ranges
NameRefers ToCells
Hol='2a'!$J$1
 
Upvote 0
Won't the holidays be a range of cells rather than a single cell, in which case that last formula wouldn't work

Possibly try an array formula like this:

=AVERAGE(IF(TEXT(A1:A14,"dddmmyy")=F1,IF(ISNA(MATCH(A1:A14,Hols,0)),B1:B14)))

confirm with CTRL+SHIFT+ENTER
 
Upvote 0
What should I do if I don't want to exclude the formulae on this one. Also, my data is horizontal. Dates are in AF2:BJ4 and the Values I need to Average are in AF4:BJ4. Any help on this would be great! Thanks!
 
Upvote 0
What should I do if I don't want to exclude the formulae on this one. Also, my data is horizontal. Dates are in AF2:BJ4 and the Values I need to Average are in AF4:BJ4. Any help on this would be great! Thanks!

What should I do if I don't want to exclude Holidays in the formulae on this one. Also, my data is horizontal. Dates are in AF2:BJ4 and the Values I need to Average are in AF4:BJ4. Any help on this would be great! Thanks!

I wanted to edit, couldn't find an option.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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