Geographic Information Systems Asked by Philippe Morgan on January 24, 2021
I would like to update a column with different strings based on other strings in another column.
For instance : if A, B, C in column 1, write Cat1 in column 2. So I use "case when". But even without writing ‘else’ when it always replace all other values by NULL. Which means that if I then want to update again the column with "if X, Y, Z in column 1, write Cat2 in column 2", "Cat1" gets deleted in all the cells where it had been added. If I don’t want to update all cells at the same time, how can I conditionally update certain cells while ignoring others (i.e. not deleting their content)?
if("Column 1" IN ('X','Y','Z'),'Cat2',"Column 2")
This checks whether the specified condition Column 1 is like X, Y, or Z
is fulfilled and then either writes Cat2
into Column 2, or uses preexisting values or Column 2 otherwise.
You could also chain several if
statements, or run a comprehensive case when when when when
expression.
Similar to your question from earlier:
CASE
WHEN "l_co" in ('Romainville','Bagnolet' ,'Bobigny','Bondy' ,'Les Lilas','Montreuil','Noisy-le-Sec' ,'Le Pré-Saint-Gervais','Pantin')
THEN 'Est Ensemble'
WHEN "l_co" in (several other city names)
THEN 'Plaine Commune group'
ELSE "EPCI"
END
Correct answer by Erik on January 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP