ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   average based on weekday (https://www.excelbanter.com/excel-worksheet-functions/37125-average-based-weekday.html)

Nick

average based on weekday
 
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.
--
Thanks,
Nick

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


"Nick" wrote in message
...
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.
--
Thanks,
Nick




Bob Phillips

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

--
HTH

Bob Phillips

"Nick" wrote in message
...
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.
--
Thanks,
Nick




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 ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Nick" wrote in message
...
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.
--
Thanks,
Nick




Nick

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

Thank you ever so much,
Nick


"Max" wrote:

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 ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Nick" wrote in message
...
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.
--
Thanks,
Nick





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" wrote in message
...
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 ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Nick" wrote in message
...
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.
--
Thanks,
Nick






Max

You're welcome !
Thanks for the feedback (from us <g) ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Nick" wrote in message
...
WOW, three great answers with three different approachs
and in such a short time.

Thank you ever so much,
Nick




Max

"Bob Phillips" wrote
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.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----



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

"Max" wrote in message
...
"Bob Phillips" wrote
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.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----





Max

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

Thanks for the view ! <g
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com