How do I easily convert decimals in a legend to display as %? in the below example I want the legend to read -5% to -3.1%, -10% to -5% etc... rather than decimal places.

enter image description here

It feels like this should be simple but I haven't been able to find the answer anywhere.

2 Answers 2


Assuming you are keeping the 'to' as a separator and you have vector data you can use the legend expressions to format your label categories.

Select the layer and hit the epsilon at the bottom of the legend layertree enter image description here

After than you can use the following formula

 array_to_string(array_foreach( string_to_array(@symbol_label,'to'),(to_real(@element)*100) || '%'),' to ')

It simply split the string, format the numbers and join them back, you could use the format_number function to remove some decimals if you want.


To do so I think the best way is to use both the value based on expression and the legend format tool.

On the value based you can divied your target value by 100 or make any calculation necessary.

Then on the legend format tool you have %1 to represent your first number, %2 to have your second one. You can add any text you want before or after or between your numbers.

The advantage is that you get the same legend on your layer tree and legend in a layout.

Here is an example :

enter image description here

Your Answer

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

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