LET Function stuck

Holger

New Member
Joined
Nov 22, 2017
Messages
29
Office Version
  1. 365
Platform
  1. MacOS
Hi there,

I'm trying to solve problems with the LET function and with a new challenge I'm stuck again. I have some investment assumptions, for which I would like to create a table that shows when how much interest is earnt/paid. Screenshot 1 has the assumption, Screenshot 2 what I want to achieve.

Interest days are the diff between payment days (and in the case of the first payment diff between payment date and investment start). Invest1Pay is. range B11:B14 and contains the interest payment dates.

As the second screenshot shows, I can't get the loop working. The current formula is as follows:

=LET(
invest,B5,
start, B6,
end, B8,
a_rate, B9,
d_rate, a_rate/365,
p_day, VSTACK(Invest1Pay),
int_days,p_day-p_day,
p_count,COUNT(p_day),
int_paid, d_rate*int_days*invest,
VSTACK(
VSTACK({"Amount","Start","End","Annual Rate","Daily Rate","Pay Date","Interest Days","Interest Paid"}),
HSTACK(invest, start,end, a_rate, d_rate,p_day,int_days, int_paid)
))


Thank You so much everyone for assisting on this.

Cheers H
 

Attachments

  • Screenshot 2025-01-11 at 11.08.09.png
    Screenshot 2025-01-11 at 11.08.09.png
    56.1 KB · Views: 8
  • Screenshot 2025-01-11 at 11.03.35.png
    Screenshot 2025-01-11 at 11.03.35.png
    28.1 KB · Views: 8

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

so I made some progress and now have the cum interest paid and cum number of interest days.

What I still need assistance with is:

* how do I change column <<Count Days" to show only the number of days for that period. First row 36 is okay (from start date to first payment date). 2nd row 128 needs to deduct previous period days so result would be 92 days (from 05/11/2024 to 05/02/2025.......
* same for interest, how do I show interest for period not only cum interest.
* how to I get ride of #N/A in col Amount, Start, End, Daily Rate?

HeinWealthFile.xlsx
STUVWXYZ
32CountAmountStartEndDaily RatePay DateCount DaysCum Int Paid
331800,00030/09/20245/06/20250.05%5/11/20243613,414
342#N/A#N/A#N/A#N/A5/02/202512847,693
353#N/A#N/A#N/A#N/A5/05/202521780,855
364#N/A#N/A#N/A#N/A5/06/202524892,405
Investments
Cell Formulas
RangeFormula
S32:Z36S32=LET( invest,B5, start,B6, end,B8, d_rate,B9/365, p_day,VSTACK(Invest1Pay), npers,COUNT(p_day), pers,SEQUENCE(npers), d_count,p_day-start, int_paid,d_rate*invest*d_count, days,SCAN(start,d_count,LAMBDA(a,b,a-b)), VSTACK( VSTACK({"Count","Amount","Start","End","Daily Rate","Pay Date","Count Days","Cum Int Paid"}), HSTACK(pers,invest,start,end,d_rate,p_day,d_count,int_paid) ))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Invest1Pay=Investments!$B$11:INDEX(Investments!$B$11:$B$20,SUMPRODUCT(--(Investments!$B$11:$B$20<>"")))S32



thanks for any help
 
Upvote 0
Hi Everyone,

so slowly solving this by myself ;) step by step. Now I have got this far and two minor tasks outstanding:

1. how do I repeat start and en with same date for all rows in the array? I managed to achieve this for invest and d_rate by defining inv and rate. However this does not work for dates in start and end>


HeinWealthFile.xlsx
STUVWXYZ
32CountAmountStartEndDaily RatePay DateInt DaysInt Paid
331800,00030/09/20245/06/20250.05%5/11/20243613,413.70
342800,000#N/A#N/A0.05%5/02/20259234,279.45
353800,000#N/A#N/A0.05%5/05/20258933,161.64
364800,000#N/A#N/A0.05%5/06/20253111,550.68
Investments
Cell Formulas
RangeFormula
S32:Z36S32=LET( invest,B5, start,B6, end,B8, d_rate,B9/365, p_day,VSTACK(Invest1Pay), npers,COUNT(p_day), pers,SEQUENCE(npers), inv,SEQUENCE(npers,,invest,0), rate, SEQUENCE(npers,,d_rate,0), help_count,DROP(VSTACK(start,p_day),-1), d_count,p_day-start, int_days, p_day-help_count, int_paid,d_rate*invest*int_days, VSTACK( VSTACK({"Count","Amount","Start","End","Daily Rate","Pay Date","Int Days","Int Paid"}), HSTACK(pers,inv,start,end,rate,p_day,int_days, int_paid) ))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Invest1Pay=Investments!$B$11:INDEX(Investments!$B$11:$B$20,SUMPRODUCT(--(Investments!$B$11:$B$20<>"")))S32


Any help would be greatly appreciated.
 
Upvote 0
So here is the solution to my own question as everything works now just fine. I'm sure that this is not the most efficient way so anyone willing to assist in make this more efficient, would be greatly appreciated as it allows to learn.

HeinWealthFile.xlsx
STUVWXYZ
32CountAmountStartEndDaily RatePay DateInt DaysInt Paid
331800,00030/09/20245/06/20250.05%5/11/20243613,413.70
342800,00030/09/20245/06/20250.05%5/02/20259234,279.45
353800,00030/09/20245/06/20250.05%5/05/20258933,161.64
364800,00030/09/20245/06/20250.05%5/06/20253111,550.68
Investments
Cell Formulas
RangeFormula
S32:Z36S32=LET( invest,B5, start,B6, end,B8, d_rate,B9/365, p_day,VSTACK(Invest1Pay), npers,COUNT(p_day), pers,SEQUENCE(npers), inv,SEQUENCE(npers,,invest,0), rate, SEQUENCE(npers,,d_rate,0), s, SEQUENCE(npers,,start,0), e, SEQUENCE(npers,,end,0), help_count,DROP(VSTACK(start,p_day),-1), d_count,p_day-start, int_days, p_day-help_count, int_paid,rate*inv*int_days, VSTACK( VSTACK({"Count","Amount","Start","End","Daily Rate","Pay Date","Int Days","Int Paid"}), IFNA(HSTACK(pers,inv,s,e,rate,p_day,int_days, int_paid),0) ))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Invest1Pay=Investments!$B$11:INDEX(Investments!$B$11:$B$20,SUMPRODUCT(--(Investments!$B$11:$B$20<>"")))S32
 
Upvote 0
The IF function can be used to broadcast a horizontal vector downwards by supplying the logical_test argument with a vertical vector of TRUE values, and since any numeric value other than zero is interpreted as TRUE, the pers variable can be used in this scenario: IF(pers,HSTACK(invest,start,end,d_rate)).
Excel Formula:
=LET(
    invest, B5,
    start, B6,
    end, B8,
    d_rate, B9/365,
    p_day, Invest1Pay,
    pers, SEQUENCE(ROWS(p_day)),
    int_days, p_day-DROP(VSTACK(start,p_day),-1),
    int_paid, d_rate*invest*int_days,
    VSTACK(
        {"Count","Amount","Start","End","Daily Rate","Pay Date","Int Days","Int Paid"},
        HSTACK(pers,IF(pers,HSTACK(invest,start,end,d_rate)),p_day,int_days,int_paid)
    )
)
I hope that helps! :)
 
Upvote 0
The IF function can be used to broadcast a horizontal vector downwards by supplying the logical_test argument with a vertical vector of TRUE values, and since any numeric value other than zero is interpreted as TRUE, the pers variable can be used in this scenario: IF(pers,HSTACK(invest,start,end,d_rate)).
Excel Formula:
=LET(
    invest, B5,
    start, B6,
    end, B8,
    d_rate, B9/365,
    p_day, Invest1Pay,
    pers, SEQUENCE(ROWS(p_day)),
    int_days, p_day-DROP(VSTACK(start,p_day),-1),
    int_paid, d_rate*invest*int_days,
    VSTACK(
        {"Count","Amount","Start","End","Daily Rate","Pay Date","Int Days","Int Paid"},
        HSTACK(pers,IF(pers,HSTACK(invest,start,end,d_rate)),p_day,int_days,int_paid)
    )
)
I hope that helps! :)
Awesome DJLet 😉 that works and is much, much shorter. Appreciate the time to look at this and your feedback.

Cheers H
 
Upvote 0

Forum statistics

Threads
1,225,635
Messages
6,186,128
Members
453,340
Latest member
Stu61

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