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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Merging Rows.....in different columns

Part NoCreation DateETD
201020-12-201321-12-2013
201021-12-201322-12-2013
201122-12-201322-12-2013
201123-12-201324-12-2013
201024-12-201325-12-2013
201025-12-201325-12-2013

The above is data

Expected result in qlikview:-

Note:-

The First ETD date for a particular part no should be considered as ETD1,

The Second ETD date for a particular part no should be considered as ETD2, and so on.

1 Solution

Accepted Solutions
sbaldwin
Partner - Creator III
Partner - Creator III

Hi what you are trying to do is essentially the reverse of a cross table, below is a script which does this for your example few records, hope this helps.

Thanks

Steve

temp:

LOAD

part_no,

etd,

rowno() as rk

INLINE [

    part_no, creation_date, etd

    2010, 20-12-2013, 21-12-2013

    2010, 21-12-2013, 22-12-2013

    2011, 22-12-2013, 22-12-2013

    2011, 23-12-2013, 24-12-2013

    2010, 24-12-2013, 25-12-2013

    2010, 25-12-2013, 25-12-2013

] ;

temp2:

noconcatenate load part_no,etd,'ETD'&AutoNumber(rk,part_no) as cols

Resident temp

order by part_no,etd asc;

drop table temp;

temp:

load distinct cols Resident temp2;

let v_newcols  = NoOfRows('temp');

temp3:

load distinct part_no Resident temp2;

for i = 1 to $(v_newcols)

set v_newcol = ETD$(i);

join (temp3)

load part_no,etd as $(v_newcol) Resident temp2 where cols = '$(v_newcol)';

next i;

drop table temp2;

drop table temp;

View solution in original post

2 Replies
sbaldwin
Partner - Creator III
Partner - Creator III

Hi what you are trying to do is essentially the reverse of a cross table, below is a script which does this for your example few records, hope this helps.

Thanks

Steve

temp:

LOAD

part_no,

etd,

rowno() as rk

INLINE [

    part_no, creation_date, etd

    2010, 20-12-2013, 21-12-2013

    2010, 21-12-2013, 22-12-2013

    2011, 22-12-2013, 22-12-2013

    2011, 23-12-2013, 24-12-2013

    2010, 24-12-2013, 25-12-2013

    2010, 25-12-2013, 25-12-2013

] ;

temp2:

noconcatenate load part_no,etd,'ETD'&AutoNumber(rk,part_no) as cols

Resident temp

order by part_no,etd asc;

drop table temp;

temp:

load distinct cols Resident temp2;

let v_newcols  = NoOfRows('temp');

temp3:

load distinct part_no Resident temp2;

for i = 1 to $(v_newcols)

set v_newcol = ETD$(i);

join (temp3)

load part_no,etd as $(v_newcol) Resident temp2 where cols = '$(v_newcol)';

next i;

drop table temp2;

drop table temp;

Not applicable
Author

Sorry For Late Comment,

Thanks it works....