QGIS – Solving QGIS Joined Attributes Not Visible in Categorized Symbology Issue

attribute-joinsattribute-tableqgisqgis-3symbology

I am trying to make a thematic layer using the attributes from my now main table which were previously joined.

I would like it to look something like this:
enter image description here

As visible in picture, the columns starting with Gotenburg, Gothenbu_1 etc are in the table joined.
enter image description here

But when I try to create categories based on its values, I do not have the option to use those attributes. As seen in next photo.

enter image description here

Best Answer

To apply Graduated Symbology to numeric values with a text/string datatype, you can perform an in-place conversion using the to_int() (for integers) or to_real() (for decimal values) function in the expression builder.

Next to the drop-down box for selecting columns there is a little ε symbol. Click on that to open the Expression builder and use one of the above functions like so: to_int("Gothenburg")


In this example below showing the Graduated symbology window I have a points layer where "id" is a text field. But it does not appear in the dropdown list - only a numeric field called "numeric", so I have clicked on the symbol next to the list.

enter image description here

This opens up the Expression builder where you write your expression.

enter image description here

Now you will see the expression in the drop-down list. Click Classify and you will be able to categorise accordingly (this works even if you have NULL values, or values that could not be converted to an integer, however they won't show up on your canvas at all).

enter image description here

Note, you shouldn't ever be able to see the actual field in the drop down box ("id" in this case). It is just an expression and it's temporary - note it's italicised. If you use the Expression editor to create an expression out of a different field, that original expression will be lost.


Note however this can be memory intensive depending on the size of your dataset as it is (a) joining data and (b) converting its type. If you want to permanently change the datatype to numeric but retain the join, you need to change the way the source data is read in QGIS. If your source data is a CSV try adding it to your project using Add Delimited Text Layer (which should auto detect datatypes - although mainly from the first row, so if your first row is NULL it may interpret it as string), rather than dragging and dropping (which will always interpret all columns as text/string)

Related Question