if(len(trim(Ending_Balance)), Ending_Balance, Peek('PREnding_Balance')) as PREnding_Balance
this is from Qlik help
Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.
Fieldname must be given as a string (e.g. a quoted literal).