Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

caccio88
Contributor II

Create a new field in a table if exist values in another table

Ho everyone,

what i would like to do is to create a new field in the first table if exist values in another table.

Table1:

LOAD * INLINE [

    A

    1

    2

    3

    4

    5

    6

    7

    8

];

Table2:

LOAD * INLINE [

    A

    2

    3

    4

    10

    11

    12

];

What I'd like to do is to create a "B" field in the Table1 where the values are:

- "OK" if the value in the field A of Table1 exist in the field A of Table2;

- "KO" if the value in the field A of Table1 does not exist in the field A of Table2.

Is that clear enough?

The field "B" in the "New" Table1 should be:

B

KO

OK

OK

OK

KO

KO

KO

Here attached my qvw example.

Thank u all.

Filiberto

1 Solution

Accepted Solutions

Re: Create a new field in a table if exist values in another table

Hi,

one solution could be:

QlikCommunity_Thread_197225_Pic1.JPG

Table2:

LOAD * INLINE [

    A

    2

    3

    4

    10

    11

    12

];

Table1:

LOAD *,

    If(IsNull(Lookup('A','A',A,'Table2')),'KO','OK') as B

INLINE [

    A

    1

    2

    3

    4

    5

    6

    7

    8

];

hope this helps

regards

Marco

View solution in original post

2 Replies

Re: Create a new field in a table if exist values in another table

Hi,

one solution could be:

QlikCommunity_Thread_197225_Pic1.JPG

Table2:

LOAD * INLINE [

    A

    2

    3

    4

    10

    11

    12

];

Table1:

LOAD *,

    If(IsNull(Lookup('A','A',A,'Table2')),'KO','OK') as B

INLINE [

    A

    1

    2

    3

    4

    5

    6

    7

    8

];

hope this helps

regards

Marco

View solution in original post

Re: Create a new field in a table if exist values in another table

Another solution could be using Mapping Load:

Table2:

Mapping

LOAD * INLINE [

    A, B

    2, OK

    3, OK

    4, OK

    10, OK

    11, OK

    12, OK

];

Table1:

LOAD A,

  ApplyMap('Table2', A, 'KO') as B;

LOAD * INLINE [

    A

    1

    2

    3

    4

    5

    6

    7

    8

];


Capture.PNG