Calculating returns of a range using Product + Offset functions

gcefaloni

Board Regular
Joined
Mar 15, 2016
Messages
119
Hi,

I'm trying to calculate monthly returns of a stream of returns using an ongoing set of daily returns. So what I was trying to do was something of the sort:

A4:A10000 column = WORKDAY(daily dates)
B4:B10000 column = daily returns %
S2:S61 column = end of month dates (Jan 2019 to Dec 2023)
T2:T61 column = where I would like monthly returns %to populate next to each month in column S

Returns start at row 4; lets say we are trying to calculate Feb 2019 returns
{=PRODUCT(1+OFFSET(return of first day of the month of cell showing '02/28/2019',COUNTIFS('daily_dates',"=<"&'02/28/2019','daily_dates',">"&('02/28/2019'-DAY('02/28/2019')+1)),0,-DAYS('02/28/2019','01/31/2019'))-1)}

Which currently translates into
{=PRODUCT(1+OFFSET(INDEX(A4:B10000,MATCH((S3-DAY(S3)+1),A4:A10000,0),2),COUNTIFS($A4:$A10000,"=<"&S3,$A4:$A10000,">"&(S3-DAY(S3)+1)),0,-NETWORKDAYS(S3-DAY(S3)+1,S3))-1)}

It returns me a "#Ref" output.

So there are a few things I'm not sure about:
1- Using INDEX(A4:B10000,MATCH((S3-DAY(S3)+1),A4:A10000,0),2) give me my initial reference cell that corresponds to the first day of the month that I'm trying to calculate returns for, does that only give me the value instead of the actual cell that the Offset function could use (e.g. return -0.00027 instead of B4.). Currently returns B$4$ in evaluate formula check.
2- The countifs syntax to calculate the height of the range within the offset function using lesser than EOMonth date in S3 and first day of the month showing in S3. When evaluation the formula, it returns 0 instead of whatever the range height should be.
3- Calculating the offset range height using Networkdays. It currently seems to return the correct 20 for Feb 2019.

You guys seeing any solution/modification to what I'm doing in order to achieve the objective of simply calculating geometric monthly returns using daily returns?

Here's my current table:

A B S T
DateDaily Change %31-Jan-19
31-Jan-1928-Feb-19#Ref!
01-Feb-19-0.027%31-Mar-19#Ref!
04-Feb-19-0.252%Apr-19
05-Feb-190.193%May-19
06-Feb-190.010%Jun-19
07-Feb-190.261%Jul-19
08-Feb-19-0.020%Aug-19
11-Feb-19-0.079%Sep-19
12-Feb-19-0.061%Oct-19
13-Feb-19-0.012%Nov-19
14-Feb-190.365%Dec-19
15-Feb-19-0.056%Jan-20
18-Feb-190.027%Feb-20
19-Feb-190.059%Mar-20
20-Feb-19-0.033%Apr-20
21-Feb-19-0.170%May-20
22-Feb-190.224%Jun-20
25-Feb-190.077%Jul-20
26-Feb-190.194%Aug-20
27-Feb-19-0.330%Sep-20
28-Feb-19-0.180%Oct-20
01-Mar-190.161%Nov-20
04-Mar-19Dec-20
05-Mar-19Jan-21
06-Mar-19Feb-21
07-Mar-19Mar-21
08-Mar-19Apr-21
11-Mar-19May-21
12-Mar-19Jun-21
13-Mar-19Jul-21
14-Mar-19Aug-21
15-Mar-19Sep-21
18-Mar-19Oct-21
19-Mar-19Nov-21
20-Mar-19Dec-21
21-Mar-19Jan-22
01-Feb-19Feb-22

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 
Good, no date without value in colB. The Match in the formula should work to find the row for the last day of the month or less...so if the date stops on 10th, it returns that row. Test the Match by itself to see how it works.

I have not downloaded the file so I have idea what is in colE or colG. I did just realize that when you get the match and offset working with your data you can use the GEOMEAN function instead of product and nth root.

When I go from February to March to April, shouldn't I move the reference cell F3 to another cell that represents the beginning of the range of the new month? Also, when you determine the Nth root and the height of the offset array, by doing Match S4 - Match S3 (for Month of March), don't you use a full month's days as N even if there's only 2 days return worth of data in March ?
 
Last edited:
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The Match function is returning the row containing the last day of the month or the nearest value less than that. If your dates end at January 15th, it will show that as the row indicated by matching January 31st, the 1 in the Match function indicates “less than”. The Offset returns a range using a reference cell and the rows found by the Match functions. I have not downloaded your file and cannot at work so I only know what is in columns A, B, S and T.


I suggest that you test the Match functions on your date ranges and see how it works. Then see how to incorporate the Match into and Offset function to get a range of values in column B. Then it is easy…GEOMEAN(OFFSET(reference, rowoffset, column offset, height, width)).


Good luck.
 
Last edited:
Upvote 0
The Match function is returning the row containing the last day of the month or the nearest value less than that. If your dates end at January 15th, it will show that as the row indicated by matching January 31st, the 1 in the Match function indicates “less than”. The Offset returns a range using a reference cell and the rows found by the Match functions. I have not downloaded your file and cannot at work so I only know what is in columns A, B, S and T.


I suggest that you test the Match functions on your date ranges and see how it works. Then see how to incorporate the Match into and Offset function to get a range of values in column B. Then it is easy…GEOMEAN(OFFSET(reference, rowoffset, column offset, height, width)).


Good luck.[FONT=&quot][FONT=&quot]
[/FONT][/FONT]

Thanks a lot. I realized way too late what was happening. Your formula worked. It is just that instead of putting a 1 at the column parameter, it needed to be a 0 in order for it to stay in the same column. I think now what it was doing is offset to the column to the right of it which had somewhat similar return which is why I didn't realize earlier why it was outputting wrong results since the output was always so close to the intended answer.

This is the final formula I used:

=SUMPRODUCT(GEOMEAN(1+OFFSET($F$3,MATCH($S2,$A$3:$A$159,1),0,MATCH($S3,$A$3:$A$159,1)-MATCH($S2,$A$3:$A$159,1),1)))^((MATCH($S3,$A$3:$A$159,1)-MATCH($S2,$A$3:$A$159,1)))-1

Thanks a ton Doug.
 
Upvote 0
Great, no problem. I am glad you got it sorted out. I am not sure if the SUMPRODUCT is needed, but it works!

Doug
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,709
Members
449,118
Latest member
MichealRed

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