Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hermilogayossom
Partner - Contributor
Partner - Contributor

previous / peek does not work

Hello good day. I have a little case

As you can see in the image, I have a table with a set of id and dates, I am focused on the blue column "price_availability" since I need to take the previous value in a new column "Target" (in green color), I thought to use the previous () or peek () functions would be enough, but it doesn't work for me, you can see the last two columns, not the results.

Any ideas how to get the result I'm looking for? Any contribution is valuable, thanks.

 

Anotación 2020-07-31 132956.png

Labels (3)
2 Replies
Steven_Haught
Creator III
Creator III

You can try to do the previous function in your load like this. In a new section in the data load editor, loaded after your original table, put the following script:

Newtablename:

Load

*,
Previous(price_availability) as previous_price

;

Load
*

RESIDENT Original_table_name

Order By  orden desc ;

DROP TABLE Original_table_name;

Kushal_Chawda

You need to sort your data for peek and previous to work as expected.

So after loading your actual data, take a resident  with order by and there perform peek and previous operation

load *,

       peek(....

Resident TableName

order by precio_fecha,orden;

drop table TableName;