For creating a legend of a map, I need to get a list of unique values over multiple attribute columns of a layer. I know how to get a list of unique values within one column - is it possible to get a list of unique values over multiple columns?
Example:
Polygon 1: Field 1: x, Field 2: a, Field 3: b
Polygon 2: Field 1: a, Field 2: c, Field 3: z
Polygon 3: Field 1: x, Field 2: b, Field 3: z
Now I need a list with the values that are unique over the fields 1, 2 and 3. For the example that would be x, a, b, c, z.
I am using QGIS Version 2.14.1
-
I think it would be useful to see how you are getting the unique values in one field. The process is simple using python sets. How are your python skills?Fezter– Fezter2017年03月16日 22:33:31 +00:00Commented Mar 16, 2017 at 22:33
1 Answer 1
Your test data (layer name: Polygon
):
If a Virtual Layer
is acceptable, the syntax would be:
SELECT Distinct(Field_1) AS Field FROM Polygon
UNION
SELECT Distinct(Field_2) AS Field FROM Polygon
UNION
SELECT Distinct(Field_3) AS Field FROM Polygon
ORDER BY Field DESC
Then output would be:
Explore related questions
See similar questions with these tags.