In my Orbeon form, I am using a repeat with calculated fields within the repeat. For example, my repeat includes two integer fields, 1) total number of crayons and 2) number of clue crayons. The third field is a calculated field showing the the percentage of blue crayons. using the following Xpath expression,
if ($LMI-Bene ne 0)
then $LMI-Bene div $Total-Bene * 100 else 0
I am able to calculate the percentage. The problem comes when I add a new iteration to my repeat and even the first line stops working. I think this could be because the control names of each iteration are the same, but I'm not sure how to account for that. Any ideas?
Use the relative XPath to the value rather than the binding variable.
In example try
if (../LMI-Bene ne 0)
then ../LMI-Bene div ../Total-Bene * 100 else 0