I have the following formula that calculates yearly return:
Expanded for readability:
Is there a way to optimize it any further? I was hoping to find some way to prevent using OFFSET, for one.
Excel Formula:
=IF([@Date]>=TODAY(),NA(),IF(ROW()-ROW([#Headers])=1,0,LET(current_rows_year,YEAR([@Date]),prev_rows_year,YEAR(OFFSET([@Date],-1,0)), prev_ytd_return,OFFSET([@[YTD Return]],-1,0),IF(current_rows_year<>prev_rows_year,[@[Daily Return]],(1+prev_ytd_return)*([@Daily Return]+1)-1))))
Expanded for readability:
Excel Formula:
=IF(
[@Date]>=TODAY(),NA(),
IF(
ROW()-ROW([#Headers])=1,0,
LET(
current_rows_year,YEAR([@Date]),
prev_rows_year,YEAR(OFFSET([@Date],-1,0)),
prev_ytd_return,OFFSET([@[YTD Return]],-1,0),
IF(
current_rows_year<>prev_rows_year,[@[Daily Return]],
(1+prev_ytd_return)*([@Daily Return]+1)-1
)
)
)
)
Is there a way to optimize it any further? I was hoping to find some way to prevent using OFFSET, for one.