Weighted Average (Dynamic Date Range)

Evan11

New Member
Joined
Aug 25, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Based on the date in cell A1, I would like to make a dynamic weight average. For this specific Example I would get the start of the year for my beginning date criteria with the following formula: DATE(YEAR$A$1),1,1)) and I would get the end date for my range by using: EOMONTH($A$1,0). Those would produce the date range of 1/1/23 - 8/31/23. Based on that range criteria, I would like to get the weighted average Retained rate in column B using column D, Total Balance, as the weight.

Formula I thought would work but not returning he result I wanted is:
=SUMPRODUCT(--($A$3:$A$50>=DATE(YEAR($A$1),1,1))--($A$3:$A$50<=EOMONTH($A$1,0)),($B$3:$B$50))/SUMPRODUCT(--($A$3:$A$50>=DATE(YEAR($A$1),1,1))--($A$3:$A$50<=EOMONTH($A$1,0)),($D$3:$D$50))

Any help on this would be much appreciated so I don't have to use the static =SUMPRODUCT(B39:B46,D39:D46)/SUM(D39:D46) weighted average formula and adjust the range when I load in new data. The desired result is 80.09% weighted average %. Thank you in advance
 

Attachments

  • MrExcel Dynamic Date Wt Avg 8.25.23.jpg
    MrExcel Dynamic Date Wt Avg 8.25.23.jpg
    213.3 KB · Views: 16

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Can you post your sample data, so we don't have to type it all out.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Ya I spent about 30 minutes trying to get the add-in to work and couldn't so posted a picture. Any other good options? I think my work may have some admin permissions from allowing XL2BB
 
Upvote 0
Raw data in case it helps since XL2BB was not working for me

8/25/2023​
Total RetainedTotal ClosedTotal Balance
Jan-20
72.52%​
27.48%​
13,794,799
Feb-20
90.73%​
9.27%​
16,294,006
Mar-20
84.69%​
15.31%​
13,446,514
Apr-20
81.08%​
18.92%​
9,181,673
May-20
86.72%​
13.28%​
14,055,403
Jun-20
89.09%​
10.91%​
19,605,836
Jul-20
85.41%​
14.59%​
15,899,258
Aug-20
85.41%​
14.59%​
22,864,442
Sep-20
83.18%​
16.82%​
20,385,255
Oct-20
90.89%​
9.11%​
17,428,825
Nov-20
89.35%​
10.65%​
19,116,272
Dec-20
87.82%​
12.18%​
14,391,627
Jan-21
86.06%​
13.94%​
15,237,447
Feb-21
74.66%​
25.34%​
8,179,291
Mar-21
83.73%​
16.27%​
10,603,310
Apr-21
74.44%​
25.56%​
16,702,808
May-21
73.13%​
26.87%​
23,502,383
Jun-21
72.10%​
27.90%​
31,389,176
Jul-21
79.63%​
20.37%​
19,811,719
Aug-21
65.04%​
34.96%​
20,783,235
Sep-21
76.26%​
23.74%​
22,251,831
Oct-21
83.78%​
16.22%​
31,037,446
Nov-21
89.54%​
10.46%​
13,076,260
Dec-21
90.12%​
9.88%​
15,675,045
Jan-22
86.09%​
13.91%​
15,320,342
Feb-22
88.35%​
11.65%​
12,240,125
Mar-22
90.44%​
9.56%​
20,710,468
Apr-22
86.49%​
13.51%​
14,302,590
May-22
49.81%​
50.19%​
12,647,727
Jun-22
73.73%​
26.27%​
10,722,957
Jul-22
83.92%​
16.08%​
13,053,842
Aug-22
83.30%​
16.70%​
12,731,275
Sep-22
81.37%​
18.63%​
12,211,456
Oct-22
88.47%​
11.53%​
16,701,952
Nov-22
76.91%​
23.09%​
9,511,249
Dec-22
69.90%​
30.10%​
6,970,017
Jan-23
77.62%​
22.38%​
8,787,850
Feb-23
73.24%​
26.76%​
7,182,903
Mar-23
71.96%​
28.04%​
24,730,843
Apr-23
79.17%​
20.83%​
15,562,675
May-23
91.98%​
8.02%​
14,077,476
Jun-23
85.96%​
14.04%​
19,657,827
Jul-23
74.16%​
25.84%​
17,776,725
Aug-23
89.51%​
10.49%​
11,596,747
Sep-23
Oct-23
Nov-23
Dec-23
 
Upvote 0
1. Get a microsoft security notice saying microsoft is blocking the macros from running since the file source is untrusted despite moving it from downloads to the local drive. 2. some other error about it not being supported in this format.
 
Upvote 0
Try
Fluff.xlsm
ABCDEF
125/08/2023
2Total RetainedTotal ClosedTotal Balance
3Jan-2072.52%27.48%13,794,7990.8009259
4Feb-2090.73%9.27%16,294,006
5Mar-2084.69%15.31%13,446,514
6Apr-2081.08%18.92%9,181,673
7May-2086.72%13.28%14,055,403
8Jun-2089.09%10.91%19,605,836
9Jul-2085.41%14.59%15,899,258
10Aug-2085.41%14.59%22,864,442
11Sep-2083.18%16.82%20,385,255
12Oct-2090.89%9.11%17,428,825
13Nov-2089.35%10.65%19,116,272
14Dec-2087.82%12.18%14,391,627
15Jan-2186.06%13.94%15,237,447
16Feb-2174.66%25.34%8,179,291
17Mar-2183.73%16.27%10,603,310
18Apr-2174.44%25.56%16,702,808
19May-2173.13%26.87%23,502,383
20Jun-2172.10%27.90%31,389,176
21Jul-2179.63%20.37%19,811,719
22Aug-2165.04%34.96%20,783,235
23Sep-2176.26%23.74%22,251,831
24Oct-2183.78%16.22%31,037,446
25Nov-2189.54%10.46%13,076,260
26Dec-2190.12%9.88%15,675,045
27Jan-2286.09%13.91%15,320,342
28Feb-2288.35%11.65%12,240,125
29Mar-2290.44%9.56%20,710,468
30Apr-2286.49%13.51%14,302,590
31May-2249.81%50.19%12,647,727
32Jun-2273.73%26.27%10,722,957
33Jul-2283.92%16.08%13,053,842
34Aug-2283.30%16.70%12,731,275
35Sep-2281.37%18.63%12,211,456
36Oct-2288.47%11.53%16,701,952
37Nov-2276.91%23.09%9,511,249
38Dec-2269.90%30.10%6,970,017
39Jan-2377.62%22.38%8,787,850
40Feb-2373.24%26.76%7,182,903
41Mar-2371.96%28.04%24,730,843
42Apr-2379.17%20.83%15,562,675
43May-2391.98%8.02%14,077,476
44Jun-2385.96%14.04%19,657,827
45Jul-2374.16%25.84%17,776,725
46Aug-2389.51%10.49%11,596,747
47Sep-23
48Oct-23
49Nov-23
50Dec-23
Data
Cell Formulas
RangeFormula
F3F3=SUMPRODUCT(--($A$3:$A$50>=DATE(YEAR($A$1),1,1)),--($A$3:$A$50<=EOMONTH($A$1,0)),($B$3:$B$50),D3:D50)/SUMPRODUCT(--($A$3:$A$50>=DATE(YEAR($A$1),1,1)),--($A$3:$A$50<=EOMONTH($A$1,0)),($D$3:$D$50))
 
Upvote 1
Solution
Solution worked great, thank you so much for your help. I have marked as solved. I will next work on getting the XL2BB add-in working for any other future posts.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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