In https://www.zabbix.com/documentation/2.0/manual/config/macros/usermacros, it is documented that macros are substituted according to a precedence (makes sense). However, for each template "level" the templates are sorted by templateid. Unfortunately, it is not possible to change the templateid for a template. What this causes is that if I have several first-level templates that have macros assigned in them, I have no way to force them to be evaluated in any given order. In my opinion, it would be better to sort the templates based on the template name, not the templateid. Users can control the template name, and can therefore have some level of control over the order that the templates will be looked at for the macro substitution.