0

I have some fields with the same values after that I need to remove them. Some of the values are duplicates after I merged values from different layers and grouped them using the same ID number.

For example, if an attribute value is "5479-067, 5479-067" I'd need the result like "5479-067". I have not found a simple expression but it did not work for me:

array_to_string(array_distinct(string_to_array("result")))

enter image description here

enter image description here

enter image description here

any idea? what I did do wrong or how to solve it?

After trying the answer I need to get space between values (red line)

enter image description here

2 Answers 2

2

The expression (array_to_string(array_distinct(string_to_array("result")))) is correct, just make sure that you are using the correct delimiter. It looks like your delimiter is ', ', so try something like this: array_to_string(array_distinct(string_to_array("result", delimiter:=', ')))

4
  • It works thank you, but how I can add after "," between values like : 5372-010, 5372-013 when I tried to edit it but the results back to the doppelt one like when I try this : array_to_string(array_distinct(string_to_array("result", delimiter:=', '))) (space after ",") ??
    – Nista.geo
    Commented Jul 16 at 22:49
  • I am asking how I can get a space between values when I use your answer. because when I am using it I got no space between values after (,) I uploaded a pic to understand my question.
    – Nista.geo
    Commented Jul 16 at 23:02
  • set the delimiter to ', ', but in the array_to_string function: array_to_string(array_distinct(string_to_array("result", delimiter:=', ')), delimiter:=', ')
    – Mayo
    Commented Jul 16 at 23:05
  • I see.. it worked. many thanks!
    – Nista.geo
    Commented Jul 16 at 23:07
0

You can use the "Delete duplicates by Attribute" tool

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.