Average the last three values within a range if the day of week is MON

StormFusion

New Member
Joined
Feb 22, 2016
Messages
9
Hi,

I have values in range N12:N98 and the day of week in D12:D98 how do I get the average of the very last three values within range N12:N98 if the day is MON and the value is greater than 0

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Do you mean like this?

ABCD
9DayValue
10Sat 1 Jan 20227Last 3 positive7
11Sun 2 Jan 2022-5
12Mon 3 Jan 2022-8
13Tue 4 Jan 2022-10
14Sat 8 Jan 20220
15Sun 9 Jan 2022-10
16Mon 10 Jan 2022-5
17Tue 11 Jan 2022-10
18Sun 16 Jan 20227
19Mon 17 Jan 20226
20Tue 18 Jan 2022-4
21Fri 21 Jan 20220
22Sat 22 Jan 2022-9
23Sun 23 Jan 2022-2
24Mon 24 Jan 20221
25Thu 27 Jan 20220
26Fri 28 Jan 20222
27Sat 29 Jan 20225
28Sun 30 Jan 2022-4
29Mon 31 Jan 20222
30Wed 2 Feb 2022-4
31Sat 5 Feb 20222
32Mon 7 Feb 2022-1
33Tue 8 Feb 2022-4
34Wed 9 Feb 20228
35Thu 10 Feb 20225
36Fri 11 Feb 2022-1
37Sun 13 Feb 2022-8
38Mon 14 Feb 20223
39Wed 16 Feb 20222
40Thu 17 Feb 2022-3
41Sat 19 Feb 2022-10
42Sun 20 Feb 20226
43Mon 21 Feb 2022-6
44Wed 23 Feb 2022-7
45Thu 24 Feb 20228
46Sun 27 Feb 20224
47Mon 28 Feb 20227
48Tue 1 Mar 2022-4
Sheet1
Cell Formulas
RangeFormula
D10D10=SUM(INDEX(B10:B48,LARGE(IF((WEEKDAY(A10:A48)=2)*(B10:B48>0),ROW(A10:A48)-ROW(A10)+1),{1,2,3})))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi thank for that, however how to make it just check the three last Mondays being 28th, 21st and 14th so would ignore the - 6 but average the 7 and 3 thanks
 
Upvote 0
What version of Excel are you running?

It would be helpful if you could add that to your signature (you'll see I'm using 365) as the best solution for you may vary depending on your Excel version.
 
Upvote 0
OK, try:

ABCD
1DayValue
2Sat 1 Jan 20227Last 3 Mon's5
3Sun 2 Jan 2022-5(if pos)
4Mon 3 Jan 2022-8
5Tue 4 Jan 2022-10
6Sat 8 Jan 20220
7Sun 9 Jan 2022-10
8Mon 10 Jan 2022-5
9Tue 11 Jan 2022-10
10Sun 16 Jan 20227
11Mon 17 Jan 20226
12Tue 18 Jan 2022-4
13Fri 21 Jan 20220
14Sat 22 Jan 2022-9
15Sun 23 Jan 2022-2
16Mon 24 Jan 20221
17Thu 27 Jan 20220
18Fri 28 Jan 20222
19Sat 29 Jan 20225
20Sun 30 Jan 2022-4
21Mon 31 Jan 20222
22Wed 2 Feb 2022-4
23Sat 5 Feb 20222
24Mon 7 Feb 2022-1
25Tue 8 Feb 2022-4
26Wed 9 Feb 20228
27Thu 10 Feb 20225
28Fri 11 Feb 2022-1
29Sun 13 Feb 2022-8
30Mon 14 Feb 20223
31Wed 16 Feb 20222
32Thu 17 Feb 2022-3
33Sat 19 Feb 2022-10
34Sun 20 Feb 20226
35Mon 21 Feb 2022-6
36Wed 23 Feb 2022-7
37Thu 24 Feb 20228
38Sun 27 Feb 20224
39Mon 28 Feb 20227
40Tue 1 Mar 2022-4
Sheet1
Cell Formulas
RangeFormula
D2D2=IFERROR(AVERAGE(IF((ROW(B2:B40)>=LARGE(IF((WEEKDAY(A2:A40)=2),ROW(A2:A40)-ROW(A2)+1),3))*(WEEKDAY(A2:A40)=2)*(B2:B40>0),B2:B40)),"n/a")
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

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