Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
GhazanfarAli
Contributor
Contributor

Peek is not working

 

Hi all!

 

I am trying to calculate balance_eop using Peek function but seems like it not fully working the way as I want.

 

here is out I got in the end

GhazanfarAli_1-1643033992256.png

 

 

and the way I am calculating is 

if(%Key_LoanNumber=Peek(%Key_LoanNumber),Peek(Balance_eop)-(pmt((AnnualInterestRate_EOP/12),Duration_EOP,-Peek(balance_eop))-(Peek(balance_eop)*(AnnualInterestRate_EOP/12))),Balance_BOP) as balance_eop

 

3 Replies
MarcoWedel

what is your expected result?

GhazanfarAli
Contributor
Contributor
Author

 

HI Marco!

 

the expected result is when period is not 1 then it take balance from previous row and calculate balance based on the formula given in the script. basically it is loan amortization calculation.

 

I hope it helps.

 

Thanks in advance!

marcus_sommer

There are some important aspects by using peek():

  • field-names should be wrapped with single-quotes, like 'fieldX'
  • peek() takes the fields/field-values from the specified table - if not any is specified what usually the aim is the current created table is used which means all peek-fields must be also loaded
  • the load must be resident and you need appropriate order by statements

By new created fields you must use peek() but by others you may switch to previous(). Further I suggest to divide your calculation in smaller tasks to see which one work and which not. 

- Marcus