Need VBA Code to tm1 ti

Post Reply
manu0521
Posts: 124
Joined: Wed Nov 26, 2014 8:32 pm
OLAP Product: IBM TM1, Planning Analytics
Version: PA 2.0.5
Excel Version: 2016

Need VBA Code to tm1 ti

Post by manu0521 »

I have this code in vba macro , need to convert in ti

For i = k To n
If k > incFreq Then
myPmt = myPmt * (1 + incRate)
k = 1
End If
discnt = discnt * (1 + discntRate)
escPV = escPV + myPmt / discnt
k = k + 1
Next


Having issue where it says i =k to n , they assign K again as 1 when its greater than incFreq and that should cause a loop .I am getting an endless loop when did using while becasue of K being reassigned ,

While(K<=noOfMonhts);
if(K>IncrementFrequency);
PaymentAmount=PaymentAmount*(1+EscalationRate);
K=1;
ENDIF;
discnt=discnt*(1+discountRate);
escpv=escpv+(PaymentAmount/discnt);
K=K+1;
END;

Is there something I am missing here while converting .
Wim Gielis
MVP
Posts: 3240
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Need VBA Code to tm1 ti

Post by Wim Gielis »

This would be the literal translation, not looking at the logic or what it does / is supposed to do:

Code: Select all

i = k;
While( i <= n );
   If( k > incFreq );
      myPmt = myPmt * (1 + incRate);
      k = 1;
   EndIf;
   discnt = discnt * (1 + discntRate);
   escPV = escPV + myPmt / discnt;
   k = k + 1;
   i = i + 1:
End;
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply