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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Amina
Contributor
Contributor

Split a Table

Hello,

I have a table containing rows with sub-rows. First I need to filter on a keyword (example T) then add the sub-rows.

Example Table:

PP

PS

SPS

ART

ID

111

10

 

123456

T

111

10

01

333333

 

111

10

02

333354

 

111

20

 

544656

 

222

10

 

255455

B

222

10

01

654844

 

222

10

02

544444

 

So the aim is to filter only on lines with ID = T + sub-lines.

PP

PS

SPS

ART

ID

111

10

 

123456

T

111

10

01

333333

 

111

10

02

333354

 

 

how I can do this with the script in Qlik sense.

Thank you for your help

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

Load PP,PS,SPS,ART,ID, PP & PS as 'Key'

From YourTable

Where ID = 'T';

Concatenate

Load

Load PP,PS,SPS,ART,ID

From YourTable

Where ID is null and exists(Key,PP&PS);

 

View solution in original post

3 Replies
Or
MVP
MVP

Load PP,PS,SPS,ART,ID, PP & PS as 'Key'

From YourTable

Where ID = 'T';

Concatenate

Load

Load PP,PS,SPS,ART,ID

From YourTable

Where ID is null and exists(Key,PP&PS);

 

eddyvargas
Contributor III
Contributor III

First of all complete the blanks cells and then load only what you need

 

TempTable:
load
*,RowNo()
Inline [
PP,PS,SPS,ART,ID
111,10,,123456,T
111,10,01,333333
111,10,02,333354
111,20,,544656
222,10,,255455,B
222,10,01,654844
222,10,02,544444
];

FinalTable:
NoConcatenate
LOAD PP,PS,SPS,ART,
If(Len(Trim(ID)) > 0, ID, Peek('ID')) AS ID
RESIDENT TempTable
ORDER BY [RowNo()];

Drop Table TempTable;

NoConcatenate
LOAD *
Resident FinalTable
Where ID='T';

Drop Table FinalTable;

 

Amina
Contributor
Contributor
Author

Thank you for your reply,
using your solution, I also have PS= 20 in the result.