average based on weekday

G

Guest

I'm trying to average a column of numbers based on the day of the week.
Col A has the sequential days of the month, Col B has a number for each day.
I want to average all the numbers in Col B that are based on a weekday or
weekend.
 
B

Bernie Deitrick

Nick,

For the weekend average,

=SUMPRODUCT((WEEKDAY(A1:A365,2)>5)*B1:B365)/SUMPRODUCT((WEEKDAY(A1:A365,2)>5)*1)

For the weekday average
=SUMPRODUCT((WEEKDAY(A1:A365,2)<6)*B1:B365)/SUMPRODUCT((WEEKDAY(A1:A365,2)<6)*1)

HTH,
Bernie
MS Excel MVP
 
B

Bob Phillips

Weekends: =SUMPRODUCT(--(WEEKDAY(A2:A10,2)>5),B2:B10)
Weekdays: =SUMPRODUCT(--(WEEKDAY(A2:A10,2)<=5),B2:B10)
 
M

Max

Try, array-entered, i.e. press CTRL+SHIFT+ENTER:

For weekdays:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={1,2,3,4,5},B1:B8))

For weekends:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={6,7},B1:B8))

Adapt the ranges to suit ..
 
G

Guest

WOW, three great answers with three different approachs and in such a short
time.

Thank you ever so much,
Nick


Max said:
Try, array-entered, i.e. press CTRL+SHIFT+ENTER:

For weekdays:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={1,2,3,4,5},B1:B8))

For weekends:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={6,7},B1:B8))

Adapt the ranges to suit ..
 
B

Bob Phillips

I like this answer best Max, but haven't we been here before

=AVERAGE(IF(WEEKDAY(A1:A8,2)<=5,B1:B8))

<EVBG>

Bob

Max said:
Try, array-entered, i.e. press CTRL+SHIFT+ENTER:

For weekdays:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={1,2,3,4,5},B1:B8))

For weekends:
=AVERAGE(IF(WEEKDAY(A1:A8,2)={6,7},B1:B8))

Adapt the ranges to suit ..
 
M

Max

I like this answer best Max, but haven't we been here before
=AVERAGE(IF(WEEKDAY(A1:A8,2)<=5,B1:B8))
<EVBG>

Yes (scratch-scratch) I vaguely recollect .. the conditional formatting
episode ? <bg>. Heck, it's now confirmed as one of my several blind spots:
that 1 week = 7 days only, Bob ! Cheers.
 
B

Bob Phillips

hey Max,

Greeting from Wessex

The best part is that you used the ,2 argument to make the list simpler, but
stopped one step short

=AVERAGE(IF(WEEKDAY(A1:A8,2)={1,2,3,4,5},B1:B8))

which I think is as previous.

Be content in that the concept was the best though <g>

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top