2

In QGIS 3.22 I would like to label an area with decimal values. In the attribute table, the values are displayed separated by commas, but the areas are labelled separated by periods.

attributes table

result in map

After converting to string and replacing "." with ","

enter image description here

3

1 Answer 1

5

If you have QGIS 3.28 or newer, you can use this expression to remove the thousand separator:**

format_number("Area", places:=1, omit_group_separators:=true)

enter image description here


You need to use the format_number function as your label expression:

format_number("Area", places:=1)

It will format your real value to a string using your locale formatting (comma vs period separator).

The locale can be changed (overridden) in Options > General > Override System Locale > Locale

you can also directly override the locale in the expression:

format_number("Area", places:=1, language:='fr')

enter image description here

enter image description here

7
  • this works. thx. but... a locale separator for thousands like "space" or "." is now generated in between, eg 1 250,2 or 1.250,2 is there a way to get it this way > 1250,2?
    – stefan
    Commented Jan 24 at 12:33
  • There seem to be issues with format_number() since I can't seem to be able to remove the space thousand separator for some reason. And it shouldn't show up at all since I have unchecked the "Show group (thousand) separator" in the "Override System Locale" settings
    – Kalak
    Commented Jan 24 at 13:15
  • there seems to be no solution concerning this problem. i've tried to enable "Show group (thousand) separator" in the "Override System Locale" settings with no positive effect.
    – stefan
    Commented Jan 24 at 14:18
  • I have created an issue on the QGIS GitHub if you would like to see if anything changes or if we missed something github.com/qgis/QGIS/issues/55972
    – Kalak
    Commented Jan 24 at 14:23
  • ok :) i'll check
    – stefan
    Commented Jan 24 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.