# Calculations

Our current form is a bottom up form. Meaning we ask questions about subcomponents (child in a “parent-child” relationship) and then need to aggregate answers to draw conclusions about a higher up service (parent in the “parent-child” relationship).
The forums I’m reading in ODK say that you can make simple calculations (variable a + variable b to get the value of variable c) and you can use a single variable for relevance and I can get the logic to work for simple two statement logics, but I can’t get them to work for a multiple step logic such as:
Terrestrial Status (S)
Terrestrial Data (D)
Terrestrial Voice (V)
If D or V = ‘notworking’, then S = ‘notworking’
Else if D and V = ‘fullyoperational’, then S = ‘fullyoperational’
Else if D and V = ‘notavailable’, then S = ‘notavailable’
Else S = ‘intermittent’

What does work:
Calculate
terrestrialstatus
If((\${terrestrialvoicestatus}=‘fullyoperational’ and \${terrestrialdatastatus}=‘fullyoperational’), (‘fullyoperational’, ‘ignore’)

But then I can’t replace the value for terrestrial status with another if calculation

I’ve also tried to get a multiple relevant statement to work such as the below.
Relevant
selected(\${terrestrialdatastatus}, 'fullyoperational' and \$(terrestrialvoicestatus}, 'fullyoperational')

Hi Michael,

I don't think you can replace the value in a calculate once you store
it. Store each step of your logic in a temp calculate and make sure
the values are correct. The do some final logic on those temp
variables and store the final result in S.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Tue, Apr 8, 2014 at 6:31 PM, Michael Stevens michael.stevens.miis@gmail.com wrote:

Our current form is a bottom up form. Meaning we ask questions about subcomponents (child in a "parent-child" relationship) and then need to aggregate answers to draw conclusions about a higher up service (parent in the "parent-child" relationship).
The forums I'm reading in ODK say that you can make simple calculations (variable a + variable b to get the value of variable c) and you can use a single variable for relevance and I can get the logic to work for simple two statement logics, but I can't get them to work for a multiple step logic such as:
Terrestrial Status (S)
Terrestrial Data (D)
Terrestrial Voice (V)
If D or V = 'notworking', then S = 'notworking'
Else if D and V = 'fullyoperational', then S = 'fullyoperational'
Else if D and V = 'notavailable', then S = 'notavailable'
Else S = 'intermittent'

What does work:
Calculate
terrestrialstatus
If((\${terrestrialvoicestatus}='fullyoperational' and \${terrestrialdatastatus}='fullyoperational'), ('fullyoperational', 'ignore')

But then I can't replace the value for terrestrial status with another if calculation

I've also tried to get a multiple relevant statement to work such as the below.
Relevant
selected(\${terrestrialdatastatus}, 'fullyoperational' and \$(terrestrialvoicestatus}, 'fullyoperational')

## --

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.