I am working in a attribute table trying to format my numbers, but want to keep ending zeros. I am using format_numbers("column",sig figs). For the most part, it is working, but for example row two in the picture below, I need to zero to show to have everything line up perfectly. I am working in QGIS 3.10.4.

Any suggestions on how to do this?

enter image description here enter image description here enter image description here

  • That is not the expected behavior of the format_number function and is solved in the most recent version of QGIS latest and LTR. – Gabriel De Luca Aug 19 '20 at 22:08
  • Do I need to reset my qgis project after the calculation? – Zman3 Aug 19 '20 at 22:12
  • You need to update your QGIS version to 3.10.9, before the calculation.. – Gabriel De Luca Aug 19 '20 at 22:20
  • 1
    If you're using a numeric column, you will lose any leading and trailing zeros. If you want to keep them, you should store your data in a text/varchar column – DPSSpatial_BoycottingGISSE Aug 19 '20 at 23:38
  • 1
    Interesting, I would have thought that QGIS would have had another argument to keep tailing zeros. Ended up creating another column, setting it to text format, format_number("NDVI_mean",5). That worked. – Zman3 Aug 19 '20 at 23:58

Sounds like you figured it out. For posterity, I would set up a separate string field and use the Attributes Form to automatically reformat the values from your numeric field:

Attributes Form

Here is the result:

enter image description here

  • Yes that works, but lets say I have 100 columns. I don't think anyone would want to reformat every column. Perhaps I could take it into R and reformat it there, then export it back in??? – Zman3 Aug 20 '20 at 0:39
  • Yep, I'd say that sounds like a scripting exercise at that point. – Mike Talbot Aug 20 '20 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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