It is rather unclear what you are trying to do, or what your expected output is. I've addressed general issues with your template code, lets see if that addresses your issues:
It appears you have your opening and closing <span/>
tags muddled up. Currently your structure looks like:
<span condition>
<span replace></span>
<span condition>
<span replace></span>
</span>
<span>
<span condition>
<span replace></span>
</span>
while I suspect you really wanted:
<span condition>
<span replace></span>
<span>
<span condition>
<span replace></span>
</span>
<span condition>
<span replace></span>
</span>
You can combine the conditional spans with tal:content
attributes instead of replacing nested <span>
tags, forming:
<span condition content></span>
<span condition content></span>
<span condition content></span>
or, applied to your sample code, with some improvements to make things a little more readable:
<td style="text-align: right;"
tal:define="desc result/wkld1_desc;
totdirrn python:float(result.totdirrn);
cenmn python:float(result.cenmn);
dirhrs python:float(result.dirhrs);
vipr python:float(result.vipr);
">
<span tal:condition="python:totdirrn and desc not in ('Proceedures', 'Visits')"
tal:content="python:'%.4f' % (cenmn / (dirhrs * (totdirrn / dirhrs) / 336))">currentindex</span>
<span tal:condition="python:totdirrn and desc != 'Census'"
tal:content="python:'%.4f' % (vipr / (dirhrs * (totdirrn / dirhrs) / 336))">currentindex</span>
<span tal:condition="python:not totdirrn">0.0</span>
</td>
You perhaps want to make sure that those for float
results are already floating point values and avoid all those float()
calls in your view.
Also take into account that floating point values could be not quite zero, a value of 0.000001
is not equal to 0
but would be printed as 0.000
if you ask for a precision of 4 digits behind the comma.