Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
davyqliks
Specialist
Specialist

Get previous value using peek (previousField)

Hi,

 

In my load i have an issue where i need to populate the previous value if the field is null.

The null in the below would need to be SHELL

davyqliks_0-1663766104459.png

In my script i am using the following but i am still getting a null.

 

CandC:
Set i = 01;
Do while i <51

LOAD
"Portal Order No.",
enf$(i) as Fibre,
IF(ISNULL(enc$(i)),PEEK(enc$(PreviousField)),enc$(i)) as Part,
f%$(i) as Percentage
FROM [//////////////////////////////////]
(ooxml, embedded labels, header is 1 lines, table is sheet1)
where len(enf$(i))>1
;
if i<9 then
Let i='0'&(i+1);
else
Let i=i+1;
end if;
Loop;

 

 

Please can anyone let me know what is wrong with this line?

IF(ISNULL(enc$(i)),PEEK(enc$(PreviousField)),enc$(i)) as Part,

 

thank you

 

Daniel

Labels (2)
3 Replies
Mark_Little
Luminary
Luminary

Hi,

I don't use many loops in my Script, but it Peek function uses the following

PEEK('Field Name', 'Row No', 'table')

So would have expected something more like

IF(ISNULL(enc$(i)),PEEK(enc$(i),-1) AS Part

davyqliks
Specialist
Specialist
Author

Hi Mark,

Thank you so much for the quick reply, my issue is this was written for me a while back and i never got it working!

 

thanks for the suggestion, unfortunately the -1 is not looking right in the syntax here. see below:

 

davyqliks_0-1663768990583.png

Really appreciate your time here. thanks

 

Daniel

SerhanKaraer
Creator III
Creator III

Hello Daniel,

The field you use in PEEK must be in output table in memory: PEEK(enc$(PreviousField))

It means you have to include enc$(PreviousField) in LOAD statement.

Besides, as Mark states, you must single-quote the field name in Peek: PEEK('enc$(PreviousField)')