diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html
index b39fadb..e4cb163 100644
--- a/puppetboard/templates/_macros.html
+++ b/puppetboard/templates/_macros.html
@@ -65,7 +65,17 @@
{% for metric in config.DISPLAYED_METRICS %}
{% set path = metric.split('.') %}
{% set title = ' '.join(path) %}
- {{ "%.2g"|format(metrics[path[0]][path[1]]) }}{% else %}">0{% endif%}
+ {% if metrics[path[0]] and metrics[path[0]][path[1]] %}
+ {% set value = metrics[path[0]][path[1]] %}
+ {% if value != 0 and value|int != value %}
+ {% set format_str = '%.2f' %}
+ {% else %}
+ {% set format_str = '%s' %}
+ {% endif %}
+ {{ format_str|format(value) }}
+ {% else %}
+ 0
+ {% endif%}
{% endfor %}
{% endif %}
{%- endmacro %}