# compare value in 2 columns

## Recommended Posts

Hello ,

i have 3 columns col 1, col 2, col 3 and i want to add and to calculate col X :

col1

col2

col3

COL X

client1

v1

v1

exist

client1

v2

v1

not exist

client1

v1

v4

exist

if value ( col2 ) exist in (col3) than exist else not exist => over client 1

i cannot apply this : if col 2 = col 3 then "exist" else "not exist" because in rows 2 and 3 i will have as result not exist or in row 3 : V1 exist in col3

thank you

##### Share on other sites

is the colX you show the desired result In that case they should all be 'exist' because over the client1 there are cases in which col2=col3.

I have the impression, from the way you describe it, that this is a stepping stone towards a goal (adding values) maybe you can elaborate

##### Share on other sites

Hello,

the objective is to calculate the colX :

For each customer if the value in column 2 exists at least in onerows of column 3 then we write in column X "EXIST"else "not exist"

in this example :

col1

col2

col3

COL X

client1

v1

v1

for the client 1 : v1 exist in col 3 so : exist

client1

v2

v1

for the client 1 : v2 not exist in col 3 : not exist

client1

v1

v4

for the client 1 : v1 exist in col 3 : exist

##### Share on other sites

Would this work

CASE WHEN RXExtract(Concatenate(' ',Substitute(UniqueConcatenate([col3]) over ([col1]),',',' '),' '),Concatenate(' ',[col2],' '),1) is not null then 'exist' else 'not exist' end

##### Share on other sites

Yes it works

thank you for your help Best regards,