# Issue with calculate in XLSForms

**URL:** <https://forum.getodk.org/t/issue-with-calculate-in-xlsforms/3833>\
**Category:** Support\
**Created:** [December 3, 2014, 10:04pm UTC](https://forum.getodk.org/t/issue-with-calculate-in-xlsforms/3833 "2014-12-03T22:04:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jessicavernon](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/j/4da419/32.png) [@Jessicavernon](https://forum.getodk.org/u/Jessicavernon)\
**Post date:** [December 3, 2014, 10:04pm UTC](https://forum.getodk.org/t/issue-with-calculate-in-xlsforms/3833/1 "2014-12-03T22:04:58Z")

</div>

Hello - I have been unable to use XLSForms to convert the attached form because of an issue in "calculate" when I try to generate a random number for a spot check. I receive the following error:

Error: ODK Validate Errors:  
org.javarosa.xform.parse.XFormParseException: Invalid calculate for the bind attached to "${factor}" : Unexpected beginning of path in expression ${entries} /16

It would be wonderful if someone could take a look and let me know what I'm doing wrong. Thank you!

jessica

[KE005DataEntryReport\_v2.xls](https://getodk.b-cdn.net/uploads/default/original/1X/ad2246655a858e1eee843f02bcccccb7c3874da9.xls) (162 KB)

---

<div class="post-metadata">

**Author:** ![Koassi\_AKAKPO](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@Koassi\_AKAKPO](https://forum.getodk.org/u/Koassi_AKAKPO)\
**Post date:** [December 4, 2014, 7:53am UTC](https://forum.getodk.org/t/issue-with-calculate-in-xlsforms/3833/2 "2014-12-04T07:53:14Z")

</div>

Hi  
use ${entries} div 16

Koassi

> **···**
>
> Le mercredi 3 décembre 2014 22:04:58 UTC, jessic...@gmail.com a écrit : \> \> Hello - I have been unable to use XLSForms to convert the attached form \> because of an issue in "calculate" when I try to generate a random number \> for a spot check. I receive the following error: \> \> Error: ODK Validate Errors: \> org.javarosa.xform.parse.XFormParseException: Invalid calculate for the \> bind attached to "${factor}" : Unexpected beginning of path in expression \> ${entries} /16 \> \> It would be wonderful if someone could take a look and let me know what \> I'm doing wrong. Thank you! \> \> jessica

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [December 5, 2014, 5:02pm UTC](https://forum.getodk.org/t/issue-with-calculate-in-xlsforms/3833/3 "2014-12-05T17:02:20Z")

</div>

Correct. The numeric division operator is "div".

This is because XPath expressions are used to reference fields in your  
forms; when you type ${foo} the XLSForm converter converts that into an  
XPath expression. While the XLSForm expands these with a leading slash,  
they could also be expanded using ./ or ../ as a prefix. If the division  
operator were allowed to be "/", and spaces were optional (like in most  
numeric expressions), then if you wrote this expression:

${numerator}/${denominator}

a valid XLSForm conversion might be: ../numerator/../denominator

which resolves to a valid XPath expression for ../denominator

Because of this confusion, numeric division needed a new operator, "div".

> **···**
>
> -------- Mitch
> 
> On Wed, Dec 3, 2014 at 11:53 PM, Koassi AKAKPO [akakpo.koassi@gmail.com](mailto:akakpo.koassi@gmail.com) wrote:
> 
> > Hi  
> > use ${entries} div 16
> > 
> > Koassi
> > 
> > Le mercredi 3 décembre 2014 22:04:58 UTC, [jessic...@gmail.com](mailto:jessic...@gmail.com) a écrit :
> > 
> > > Hello - I have been unable to use XLSForms to convert the attached form  
> > > because of an issue in "calculate" when I try to generate a random number  
> > > for a spot check. I receive the following error:
> > > 
> > > Error: ODK Validate Errors:  
> > > org.javarosa.xform.parse.XFormParseException: Invalid calculate for the  
> > > bind attached to "${factor}" : Unexpected beginning of path in expression  
> > > ${entries} /16
> > > 
> > > It would be wonderful if someone could take a look and let me know what  
> > > I'm doing wrong. Thank you!
> > > 
> > > jessica
> > 
> > ## --
> > 
> > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Community" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)
