Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

load only record with matched value

Hello

If I have a table

IDProcessResult
1234SMT1NG
1234SMT1OK
5645SMT2OK
9235SMI1OK
6224SMT2OK
5645SMT1OK
6224SMT1OO

For a group of records with same ID and process, I want to keep only the record which has result= NG.

For example in the above table, for ID =1234 and process=SMT1, there are two records with different result.

I just want to keep the only record which ID=1234, process=SMT1 and result=NG.

How can I do it?

Thanks,

Josh

1 Solution

Accepted Solutions
maxgro
MVP
MVP

And what about the result <> NG?

Keep or remove?

1.png

Q:

LOAD ID,

     Process,

     Result

FROM

[https://community.qlik.com/thread/250389]

(html, codepage is 1252, embedded labels, table is @1);

Left Join (Q)

load ID, Process, sum(if(Result='NG', 1, 0)) as NGCount

Resident Q

group by ID, Process;

QQ:

NoConcatenate load *

Resident Q

Where (NGCount=1 and Result='NG') or NGCount=0;

DROP Table Q;

View solution in original post

4 Replies
aarkay29
Specialist
Specialist

Load*

From

     DB

Where

     Match(Result,'NG');

maxgro
MVP
MVP

And what about the result <> NG?

Keep or remove?

1.png

Q:

LOAD ID,

     Process,

     Result

FROM

[https://community.qlik.com/thread/250389]

(html, codepage is 1252, embedded labels, table is @1);

Left Join (Q)

load ID, Process, sum(if(Result='NG', 1, 0)) as NGCount

Resident Q

group by ID, Process;

QQ:

NoConcatenate load *

Resident Q

Where (NGCount=1 and Result='NG') or NGCount=0;

DROP Table Q;

Anonymous
Not applicable
Author

but, that will filter out all other records.

I want the table become:

IDProcessResult
1234SMT1NG
5645SMT2OK
5645SMT1OK
6224SMT2OK
6224SMT1OO
9235SMI1OK
aarkay29
Specialist
Specialist

Try this expression in the script


If(ID=peek(ID),

    If(Process=peek(Process),

          If(Result='NG',Result),

    Result),

Result) as Result;