I'm trying to display a number next to a symbol in QGIS 2.0.1 - The numbers are from an integer-field in a PostgreSQL database.
The goal is that single digit numbers get a leading 0 (zeros). Examples:
- 12 --> 12
- 10 --> 10
- 9 --> 09
- 0 --> 00
In the menu
layer properties --> labelling --> formating
I switch on "number formatting" and then enter a custom expression. I tried these two codes with various combinations of ", ' and more brackets, but none of them work:
CASE WHEN "Value" < 10 THEN rpad("Value", 2, 0) END
CASE WHEN "Value" < 10 THEN "0" || "Value" END
For any other person having trouble with this: Turn of "number formatting". It seems to be the reason why leading zeros are removed from the rpad()
function.
Enter the following in the regular "layer labeling" box:
rpad("Field", 2, 0)
and everything will work fine. But if you also activate number formatting it will take away the leading zeros.