3

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

6
  • That is not the expected behavior of the format_number function and is solved in the most recent version of QGIS latest and LTR. Commented Aug 19, 2020 at 22:08
  • Do I need to reset my qgis project after the calculation?
    – Binx
    Commented Aug 19, 2020 at 22:12
  • You need to update your QGIS version to 3.10.9, before the calculation.. Commented Aug 19, 2020 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 Commented Aug 19, 2020 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.
    – Binx
    Commented Aug 19, 2020 at 23:58

1 Answer 1

3

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

2
  • 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???
    – Binx
    Commented Aug 20, 2020 at 0:39
  • Yep, I'd say that sounds like a scripting exercise at that point. Commented Aug 20, 2020 at 6:13

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.