5

I have one "column D" with a b c values for my entities (1-2-3-4). Something like that :

 1. b
 2. c
 3. c
 4. e
 5. j
 6. b

I would like to generate a list of each different value of "column D". so I would have b,c,e,j. How can I perform this?

3
  • 2
    You could run dissolve and set the tool to dissolve by that column.
    – Erik
    Commented Jun 14, 2022 at 8:46
  • 1
    Do you want to create a column with the values?
    – Bera
    Commented Jun 14, 2022 at 8:46
  • Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Commented Oct 27, 2022 at 13:41

2 Answers 2

10

Use the Field Calculator with this expression:

array_to_string(
    array_distinct(
        array_agg(expression:="column D")
        )
    )

This expression utilizes the following functions: array_to_string(), array_distinct(), and array_agg().

6

You can create a virtual layer to fetch the distinct values

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the query:

SELECT DISTINCT "column D"
FROM myLayer;

or to get it as a single list

SELECT group_concat(nme, ', ') 
FROM (
  SELECT DISTINCT "column D" as nme 
  FROM myLayer
)

enter image description here

3

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.