Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Merging rows into one column in load script

Hi All,

          I have source data coming like below:

Client ID DateDurationCategory
1234/29/201310SD-MF
1234/29/201320SD-RET
1234/29/201315SD-OUTBOUND
1234/29/201310SD-OUTBOUND
1234/29/20135SD-OUTBOUND

         We want to to reduce the data into one row by adding these values in to one column as delimeted values and this data is very low level only final screen we want to parse this and show in the UI..  Apart from looping each and every record is there any way we can do this directly in the load script?.

Format we are expecting is :

Client ID DateDurationCategory
1234/29/201310;20;15;5SD-MF;SD-RET;SD-OUTBOUND

Thanks

Dasu.G

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try: concat( '<' & Duration & ';' & Category & '>', '$') as "Duration Category"


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

Try

Table1:

Load

     [Client ID],

     date#(Date,'MM/DD/YYYY') as Date,

     concat(Duration, ';') as Duration

     concat(Category, ';') as Category

From ...somewhere...

Group By [Client ID], Date;


talk is cheap, supply exceeds demand
nagaiank
Specialist III
Specialist III

You can use the following script:

 

LOAD

[Client ID], Date, Concat(Duration,';') as Durations, Concat(Category,';') as Categories Resident yourtablename Group By [Client ID], Date

;

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Temp:

LOAD

    *,

    1 AS Temp;

LOAD * INLINE [

ClientID,Date,Duration,Category

123,4/29/2013,10,SD-MF

123,4/29/2013,20,SD-RET

123,4/29/2013,15,SD-OUTBOUND

123,4/29/2013,10,SD-OUTBOUND

123,4/29/2013,5,SD-OUTBOUND ];

Data:

LOAD

    ClientID,

    Date,

    Concat(Duration, ';') AS Duration,

    Concat(Category, ';') AS Category   

RESIDENT Temp

GROUP BY ClientID, Date;

DROP TABLE Temp;

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable
Author

Thanks for the quick response.Is there any way I can maintain relation also in this data structure. Like I have created new column which has duration and category together with row is seperated by $ where as columns are seperated by ";"?.

Client ID DateDuration Category
1234/29/2013<10;SD-MF>$<20;SD-RET>
Gysbert_Wassenaar

Try: concat( '<' & Duration & ';' & Category & '>', '$') as "Duration Category"


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Too much to ask. Is there any way I can parse this text back to a table structure when some one clicks on client id. no further drill down.