3

I have field values that are:

  • OG_S_G4,
  • OG_S_G3,
  • OG_S_G2, etc.

and I want to change the OG to LIP whilst keeping all the text after (i.e. LIP_S_G4), is there a way to do this?

2 Answers 2

5

Create a new field with a type of text (string), and in the field calculator just use the following expression in a new field:

replace("fieldName",'OG','LIP')

where the fieldName is the name of the field that holds the texts OG_S_G4, OG_S_G3, OG_S_G2

enter image description here

0

You can add a new column using the field calculator in the attribute table of your data.

enter image description here

Using the following code you can add new data labels based on existing ones.

CASE
  WHEN "column_name"= 'OG_SG4' THEN 'LIP_S_G4'
  WHEN "column_name"= 'OG_SG3' THEN 'LIP_S_G3'
  WHEN "column_name"= 'OG_SG2' THEN 'LIP_S_G2'
END

Make sure that you set the correct output field type, in this case "Text (string)".

enter image description here

1
  • 1
    Thank you to the two people who answered my question, really helped!!!!
    – kel
    Commented Sep 12, 2023 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.