1

I have a points layer with a "Name" column.

The "Name" values are strings and similar to

'X501', 'X501.1', and 'X501.2'. 

I need to change any values like 'X501' to 'X501.0' and leave others as they are.

4
  • 3
    What have you tried?
    – PolyGeo
    Jun 11, 2021 at 4:14
  • 4
    Sound like a pure Python issue, testing for strings that don't contain a '.' and appending a ".0"
    – Vince
    Jun 11, 2021 at 4:18
  • I tried various forms of the following but clearly don't know the syntax well enough. IF ('Line' contains ".", "Line", "Line"&"0.0") Jun 11, 2021 at 5:58
  • Ok think I'm getting closer... IF ("Line" LIKE '%.%', "Line", "Line"+".0") almost works Jun 11, 2021 at 6:02

2 Answers 2

1

Try one of these expressions:

if("Name"='X501','X501.0',"Name")

or

if(regexp_match("Name",'^X501$'),'X501.0',"Name")

References:

1
  • Thanks for your input, I need something that works for multiple entries and different numbers, not just 'X501'... so maybe numeric wildcards or similar Jun 11, 2021 at 5:56
1

Figured it out just now, this works perfectly:

IF ("Line" LIKE '%.%', "Line", concat("Line",'.0'))

Your Answer

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

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