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!
DateValue
1/1/201810
1/2/201820
1/3/201810
1/4/201820
1/5/201810
1/6/201820
1/7/2018...10
12/30/201820
12/31/201810

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,215,840
Messages
6,127,219
Members
449,370
Latest member
kaiuuu

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