Dynamic SumProduct Formula

subtleskeptic

New Member
Joined
Sep 11, 2016
Messages
46
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello all, I have a spreadsheet with three columns

A = prices
B = Quantities
C = Dates

in:
D1 = Id like to return a weighted 1 month avg
D2 = Weighted 3 month avg
D3 = Weighted average YTD.

However, this dataset of A/B/C is updated everyday - so basically D1 needs to take the previous 21 business from today (not 30 calendar days) to calculate the 1 month weighted avg, and D2, 3 months back, and D3 YTD.

Ive tried using an offset but it doesnt seem like its working - any ideas please?

Thanks!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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’)

Maybe
+Fluff 1.xlsm
ABCD
1
28101/05/2021
32202/05/2021
416303/05/2021
58404/05/2021
612505/05/2021
715606/05/2021
810707/05/2021
95808/05/2021
1017909/05/2021
1131010/05/2021
12131111/05/2021
1361212/05/2021
14131313/05/2021
15131414/05/2021
16101515/05/2021
17181616/05/2021
1861717/05/2021
19191818/05/2021
2081919/05/2021
2182020/05/2021
2262.5
Lists
Cell Formulas
RangeFormula
D22D22=SUMPRODUCT((C2:C200>=TODAY()-21)*(C2:C200<=TODAY()),A2:A200,B2:B200)/COUNTIFS(C2:C200,">="&TODAY()-21,C2:C200,"<="&TODAY())
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
So - using your data - i get a sumproduct weighted average value of 10.92857, any idea please?

Thanks

=SUMPRODUCT(B2:B21,C2:C21/SUM(C2:C21))
 
Upvote 0
Because you are dividing the dates by the sum of the dates.
 
Upvote 0
thats my typo sorry, had copy pasted your sheet into mine.

so,
=SUMPRODUCT(A2:A21,B2:B21/SUM(B2:B21))

returns 10.92857
 
Upvote 0
If you ignoring the dates, then that is the correct result if you want the average price per unit.
For the average per unit my formula would be
Excel Formula:
=SUMPRODUCT((C2:C200>=TODAY()-21)*(C2:C200<=TODAY()),A2:A200,B2:B200)/SUMIFS(B2:B200,C2:C200,">="&TODAY()-21,C2:C200,"<="&TODAY())
 
Upvote 0
Solution
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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