# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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:

A

1

2

3

4

5

6

7

8

];

Table2:

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

Tags (2)
1 Solution

Accepted Solutions
Highlighted
MVP

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

Hi,

one solution could be:

```Table2:
A
2
3
4
10
11
12
];

Table1:
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

2 Replies
Highlighted
MVP

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

Hi,

one solution could be:

```Table2:
A
2
3
4
10
11
12
];

Table1:
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

MVP

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

Another solution could be using Mapping Load:

Table2:

Mapping

A, B

2, OK

3, OK

4, OK

10, OK

11, OK

12, OK

];

Table1:

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

A

1

2

3

4

5

6

7

8

];