I'm trying to write an expression which will return a TRUE or 1 type result if the string in "column3" is the same as the string in either "column2" or "column1".
I've tried "column3" IN ("column2","column1") which would seem logically to do the job, but it just returns a blank cell.
I'm using QGIS 2.6.
Answer
I would use CASE ELSE.
Let's say you have three columns called "a", "b" and "c". You want to check column "a" if it matches the string in either "b" or "c", and on each row where it matches you want to output a 1 in another column called "bool".
Update column "bool" with this code in the field calculator:
CASE WHEN
"a" = "b" OR
"a" = "c" THEN 1 ELSE 0 END
I just tested it and it works for me.
No comments:
Post a Comment