Creation of a counter variable that calculates the 24 compensation

1. What is the problem? Be very detailed.
Hello, I'm trying to create a variable that shows me the number of time remaining (in 24 hours) for the previously selected activities. However, it seems to me that when loading my .xls sheet, my 10th calculation variable is automatically cut pfff.

this is the error msg :

'ODK Validate Errors:

XForm is invalid. See below for the errors.

org.javarosa.xform.parse.XFormParseException: Invalid calculate for the bind attached to "${I80910}" : Couldn't understand the expression starting at this point: .../I8091 =null,0,\xcd\x8e$ in expression 24-if( ${I8011} =null,0, ${I8011} )-if( ${I8021} =null,0, ${I8021} )-if( ${I8031} =null,0, ${I8031} )-if( ${I8041} =null,0, ${I8041} )-if( ${I8051} =null,0, ${I8051} )-if( ${I8061} =null,0, ${I8061} )-if( ${I8071} =null,0, ${I8071} )-if( ${I8081} =null,0, ${I8081} )-if( ${I8091} =null,0,$

Result: Invalid'

2. What app or server are you using and on what device and operating system? Include version numbers.
ONA
3. What you have you tried to fix the problem?
24-if(${I8011}=null,0,${I8011})-if(${I8021}=null,0,${I8021})-if(${I8031}=null,0,${I8031})-if(${I8041}=null,0,${I8041})-if(${I8051}=null,0,${I8051})-if(${I8061}=null,0,${I8061})-if(${I8071}=null,0,${I8071})-if(${I8081}=null,0,${I8081})-if(${I8091}=null,0,${I8091})
4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
'ODK Validate Errors:

XForm is invalid. See below for the errors.

org.javarosa.xform.parse.XFormParseException: Invalid calculate for the bind attached to "${I80910}" : Couldn't understand the expression starting at this point: .../I8091 =null,0,\xcd\x8e$ in expression 24-if( ${I8011} =null,0, ${I8011} )-if( ${I8021} =null,0, ${I8021} )-if( ${I8031} =null,0, ${I8031} )-if( ${I8041} =null,0, ${I8041} )-if( ${I8051} =null,0, ${I8051} )-if( ${I8061} =null,0, ${I8061} )-if( ${I8071} =null,0, ${I8071} )-if( ${I8081} =null,0, ${I8081} )-if( ${I8091} =null,0,$

Result: Invalid'

Hi @bikmath
welcome to the forum! Please introduce yourself here!

could you attach a sample xls form to help us understand your problem?

bt24012020.xls (51 KB)

I don't know why it doesn't work. From I8091, it looks like the code in the computer is cut pfff.

HI, Grzesiek 2010,

CAN YOU HELP ME PLEASE!!!

You can probably vastly optimize your calculations, which may help. Specifically, you currently have:

${I80110} = 24 - if(${I8011}=null,0,${I8011})
...
${I80210} = 24 - if(${I8011}=null,0,${I8011}) - if(${I8021}=null,0,${I8021})
...
${I80310} = 24 - if(${I8011}=null,0,${I8011}) - if(${I8021}=null,0,${I8021}) - if(${I8031}=null,0,${I8031})
...

But ${I80210} includes the same sub-calculation performed by ${I80110} , so can be simplified to:

${I80210} = ${I80110} - if(${I8021}=null,0,${I8021})

and in turn

${I80310} = ${I80210} - if(${I8031}=null,0,${I8031})

You may be (eventually) hitting an internal stack overflow or somesuch... I'd first start by cleaning up the equations to reduce unnecessary recalculations; this will also have the benefit of increasing response times.

Also please note you can simplify if(${foo}='',0,${foo}) to coalesce(${foo},0), if the intention here is to make unanswered questions contribute 0... See coalesce() for details.

1 Like

Thanks for your help.

I tried this option with the if function, however it only works when the selected activities are consecutive.

In other words, with the "simplified calculation" method and the use of the function if when I select the first and last activity it doesn't work.

The simplification logic is correct, but you may have to change your SECTION851 group to not be a field-list. Unfortunately calculations within the same field-list are not currently recomputed as things change; see https://github.com/opendatakit/collect/issues/3211. This probably explain what you are seeing... sorry.

1 Like

ahhhhh that must be it !!!

and to think that I wasted enough time wondering where the mistake came from pffffff.

Thank you so much Xiphware !!!!