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.
This opens up the Expression builder where you write your expression.
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).
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)