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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Bansal_Kumar
Contributor II
Contributor II

Getting the Previous Values using peek() or previous()

Hi Experts.

I need your help in the following.

Data : 

PdateContryDEPTPLACEVALUE
1-Jan-21INDIAAABBGET
5-Jan-21INDIAAABBBUY
10-Jan-21INDIAAABBBUY

 

Output :

P_dateContryDEPTPLACEVALUEGet_date
5-Jan-21INDIAAABBBUY1-Jan-21
10-Jan-21INDIAAABBBUY1-Jan-21

 

In this case, whenever we have a column whose value is "BUY" then it has to search if there is a Value "GET" previously and insert the p_date in the new column. so for each BUY we need to get the previous "Get" date.

In the load script.

Please help.

 

Labels (1)
1 Reply
Kushal_Chawda
MVP
MVP

@Bansal_Kumar  may be this

map_get_date:
mapping LOAD Distinct Contry & DEPT & PLACE as Key,
     Pdate
FROM Table
where VALUE ='GET';

Final:
LOAD *,
     applymap('map_get_date',Contry & DEPT & PLACE,'NA') as get_date
FROM Table
where VALUE ='BUY';