Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
muratakkemik
Contributor III
Contributor III

2 row to 1 column scripting

Hi,

I have data like this below (in Resident table);

ARTIKELLOPNR, ARTIKELID, EANColor, EANSize, EANKOD RN

1111                         A                    Black     L               11111           1

1111                         A                    Black     L                12121          2

1111                         A                    White     L               34343           1

1111                         A                    White     L               55555           2

2222                        B                    Black     M               66666          1

2222                        B                    Black     M               77777          2

3333                         C                   Red       S                65766          1

4444                         D                   Red       XL               34321          1

.....

  

I need this format (with QV script);

ARTIKELLOPNR, ARTIKELID, EANColor, EANSize, EANKOD1, EANKOD2

1111                         A                    Black          L               11111          12121

1111                         A                    White          L               34343          55555

2222                         B                    Black          M              66666          77777

3333                         C                    Red             S              65766          65766

4444                         D                    Red            XL             34321          34321

...

every ARTIKELLOPNR & ARTIKELID & EANColor & EANSize must be one line in table.


Thanks

Murat

6 Replies
swuehl
MVP
MVP

Maybe like this:

 

Result:
LOAD ARTIKELLOPNR, ARTIKELID, EANColor, EANSize,
	Only(If(RN = 1, EANKOD)) as EANKOD1,
	Alt(Only(If(RN = 2, EANKOD)),Only(If(RN = 1, EANKOD))) as EANKOD2
Resident Table 
GROUP BY ARTIKELLOPNR, ARTIKELID, EANColor, EANSize; DROP TABLE Table;

 

 

//testing posting a reply on the new platform for the first time,

sunny_talwar

Stefan - 

How did you get a box around the script?

Thanks,

Sunny

swuehl
MVP
MVP

In the rich text menu, there is a tag for code block </>.

 

Code blockCode block

sunny_talwar

Thanks Stefan!!

MarcoWedel

Hi,

if you don't need the redundant EANKOD2 in case there is only one row, then maybe a generic load might do as well:

QlikCommunity_Thread_20181115_0137_Pic1.JPG

table1:
Generic
LOAD ARTIKELLOPNR,
     ARTIKELID,
     EANColor,
     EANSize,
     'EANKOD'&RN,
     EANKOD
Inline [
    ARTIKELLOPNR, ARTIKELID, EANColor, EANSize, EANKOD, RN
    1111, A, Black, L, 11111, 1
    1111, A, Black, L, 12121, 2
    1111, A, White, L, 34343, 1
    1111, A, White, L, 55555, 2
    2222, B, Black, M, 66666, 1
    2222, B, Black, M, 77777, 2
    3333, C, Red, S, 65766, 1
    4444, D, Red, XL, 34321, 1
];

hope this helps

regards

Marco

 

Anonymous
Not applicable

Well, you could just load new table with distinct statement resident from this one without last field