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 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 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.