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")))
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)
2 Answers 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:=', ')))
-
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– Nista.geo2024年07月16日 22:49:35 +00:00Commented 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.Nista.geo– Nista.geo2024年07月16日 23:02:44 +00:00Commented Jul 16, 2024 at 23:02
-
set the delimiter to
', '
, but in thearray_to_string
function:array_to_string(array_distinct(string_to_array("result", delimiter:=', ')), delimiter:=', ')
Mayo– Mayo2024年07月16日 23:05:43 +00:00Commented Jul 16, 2024 at 23:05
You can use the "Delete duplicates by Attribute" tool
Explore related questions
See similar questions with these tags.