QGIS – Unable to Change Decimal Points in Field Calculator Results

field-calculatorqgisqgis-modeler

When I use the modeler (Pic. 1, Layer: "Gemeindegrenze/2500 m Radius" – yellow mark), the results are always shown in a value with 16 decimal points (Pic. 2) and It seems to be impossible to change it for 2 decimal points, while using the value expression (Pic. 2, red mark), even when I set up 2 decimal points (Pic. 2, orange mark) it is not working out. I found out that it does show me the number in 2 decimal points when I change the value expression to "area_perce", while keep the setup for 2 decimal points (orange mark). But in that way I can`t name the area in the map.

On the other hand (Pic. 1, Layer: "Gemeindegrenze" – blue mark), I also found out that when I skip the field calculator by using the modeler and calculate the "area_perce" (percentage of area) only by field calculator (by hand), it works perfectly with the value expression (Pic. 3, red mark) and does'nt even need to set up the number of decimal points (Pic. 3, orange mark). So I am pretty sure that the problem is somewhere in the field calculation from the modeler.
At both layers I use a format template that I saved before, to have same settings and changing the result field type or result field length (Pic. 1, brown mark) did`nt change anything.

enter image description here

enter image description here

enter image description here

Best Answer

As your are using || to concatenate strings your value in area_perce will be handled as a string as well, ergo the "Format Numbers" which you set to two decimals will be ignored. For your labels you can try this expression:

"GEN" || ': ' || round("area_perce",2) || '%'

this will reduce the decimals to two before it's type is converted to string

Related Question