Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sudhakar_budde
Creator
Creator

Data Transformation using Inter record functions

Hi,

Can any one help me with my following requirement please?

I have the below data 

SnapshotDateProductStartedDateEndDate
07/01/2018A01/01/2018-
25/02/2018A-03/03/2018
11/03/2018A05/03/2018-
18/03/2018A-24/03/2018
01/04/2018A26/03/201807/04/2018
15/04/2018A09/04/2018-
11/08/2019A-30/12/2099

 

I want like this 

ProductStartedDateEndDate
A01/01/201803/03/2018
A05/03/201824/03/2018
A26/03/201807/04/2018
A09/04/201830/12/2099

 

Thanks in advance.

 

SB

Labels (2)
5 Replies
MayilVahanan

HI
Try like this


Temp:
LOAD * INLINE [
SnapshotDate, Product, StartedDate, EndDate
07/01/2018, A, 01/01/2018,
25/02/2018, A,, 03/03/2018
11/03/2018, A, 05/03/2018,
18/03/2018, A,, 24/03/2018
01/04/2018, A, 26/03/2018, 07/04/2018
15/04/2018, A, 09/04/2018,
11/08/2019, A,, 30/12/2099
];

Load Product, StartedDate, if(Len(Trim(Previous(EndDate)))>0, Previous(EndDate), EndDate) as EndDate Resident Temp
where Len(Trim(StartedDate)) > 0order by SnapshotDate desc;

DROP Table Temp;
Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sudhakar_budde
Creator
Creator
Author

Hi Mayilvahan,

Thanks for your response!

The code is working only for the data set that I provided here. But this is a subset of data in a bigger table where there many other Products. So, somehow it's not working on the whole data set!

I tried this but it's not working:


 Load
Product,
StartedDate
 ,if(Product=Peek(Product) and Len(Trim(Previous(EnddDate)))>0, Previous(EnddDate), EnddDate) as EndDate
 Resident Temp
where Len(Trim(StartedDate)) > 0 order by SnapshotDate desc;

 

Thanks

 

SB

Brett_Bleess
Former Employee
Former Employee

Sudhakar, try the following Help link, you should find what you need there I believe, not sure the Resident is what you need here, suspect you need an actual data source like an Excel file etc...

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

There are a bunch of examples at the bottom of the link, just expand those to find the ones that may help you here.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Saravanan_Desingh

One solution is..

SET DateFormat='DD/MM/YYYY';

tab1:
LOAD RowNo() As RowID, * INLINE [
SnapshotDate, Product, StartedDate, EndDate
07/01/2018, A, 01/01/2018,
25/02/2018, A, , 03/03/2018
11/03/2018, A, 05/03/2018,
18/03/2018, A, , 24/03/2018
01/04/2018, A, 26/03/2018, 07/04/2018
15/04/2018, A, 09/04/2018,
11/08/2019, A, , 30/12/2099
];

tab2:
LOAD *, RowNo() As K1
Resident tab1
Where StartedDate<>''
;

tab3:
LOAD *, RowNo() As K2
Resident tab1
Where EndDate<>''
;

tab4:
NoConcatenate
LOAD Product, StartedDate, K1
Resident tab2;
Left Join(tab4)
LOAD Product, EndDate, K2 As K1
Resident tab3;

Drop Table tab1, tab2, tab3;
Drop Field K1;
Saravanan_Desingh

commQV73.PNG