1

Is there a way to format the way attribute values are displayed in the attribute table?

For example, I would rather display the following columns to show comma-separated thousands and without the zeroes after the decimal point.

unformatted view attribute table

So, instead of "2300000.00000", it would display as "2,300,000" instead.

2 Answers 2

2

You cannot format the numbers directly, you need to create a field of type String first then use the following formula using Field Calculator in QGIS:

format_number(Field_name,0)

The format number is located under String category that's why creating a field of type String is necessary.

For example if you have a field of type Real with a name X , then add a field of type String and the formula will be format_number("X",0). The 0 is to remove any decimal places and add comma-separated thousands.

3
  • I'm knocking myself on the head for not remembering how powerful the Field Calculator is! Thank you @ahmadhanb
    – n1kn0k
    Commented Aug 3, 2016 at 0:22
  • It works great but it would be nice to have a 'format' option in Layer properties -> Fields.
    – Victor
    Commented Aug 4, 2016 at 14:45
  • @Victor I agree with you, I hope it can be added in the future.
    – ahmadhanb
    Commented Aug 4, 2016 at 14:56
0

Great answer from @ahmadhanb which as mentioned, there doesn't seem to be away (yet) to change the formatting display of the attribute table! Another method is to use the Float to Text tool from the MMQGIS plugin, this tool converts your float fields into string automatically and outputs the result as a new shapefile. You can download/enable the plugin from the menubar.

Plugins > Manage and Install Plugins...

  1. Example attribute table:

    Example attribute table

  2. From the menubar:

    MMQGIS > Modify > Float to Text
    

    Float to Text

  3. Set the relevant options (the output must be saved somewhere other than the temp folder)

    Float to Text options

  4. Result:

    Result

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.