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

Taras
35.8k5 gold badges77 silver badges151 bronze badges
asked Jul 16, 2024 at 20:22

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:=', ')))

answered Jul 16, 2024 at 22:15
3
  • 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 ",") ?? Commented Jul 16, 2024 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. Commented Jul 16, 2024 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:=', ') Commented Jul 16, 2024 at 23:05
0

You can use the "Delete duplicates by Attribute" tool

answered Jul 17, 2024 at 12:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.