# Calculations across repeats

I'm trying to understand if it's possible to make calculations across repeats (not inside that's working perfectly).

In example, in every group I put inside the calculation of the (sub)total cost, calculated by multiplicating "Unit No." and "Unit Price".
Once the enumerator has compiled all the repeats, I'd like to have a calculated field where I display the Grand Total, given by the sum of each single (sub)total.

Is it possible to implement in ODKCollect-JavaROSA?

And if it's also possible to use multiplication instead of the sum operations?

I attach an example form in excel I'm trying to implement for demo purpose.

Thanks

Marco

Test_Case.xls (464 KB)

Hi Marco,

You can use sum() to add up values inside repeats. You just need to add a
step inside your repeat to make sure a value is never empty (depending on
your case, you can either use a default of 0 or use an if() statement to do
this).
.

P.S. This question would be the for the ODK Community forumhttps://groups.google.com/forum/#!forum/opendatakit(not the developers forum).

Cheers,
Martijn

··· On Thursday, January 9, 2014 6:45:13 AM UTC-7, ma.g...@gmail.com wrote: > > I'm trying to understand if it's possible to make calculations across > repeats (not inside that's working perfectly). > > In example, in every group I put inside the calculation of the (sub)total > cost, calculated by multiplicating "Unit No." and "Unit Price". > Once the enumerator has compiled all the repeats, I'd like to have a > calculated field where I display the Grand Total, given by the sum of each > single (sub)total. > > Is it possible to implement in ODKCollect-JavaROSA? > > And if it's also possible to use multiplication instead of the sum > operations? > > I attach an example form in excel I'm trying to implement for demo purpose. > > Thanks > > Marco > >

Hi Martin,

I've realized that our application was based on a very old version of ODK that didn't support that operation.
So I was thinking that we need to modify in some way the code of ODK to make it work.
Thanks

Cheers,
Marco

··· Il giorno venerdì 10 gennaio 2014 01:33:02 UTC+1, Martijn van de Rijdt ha scritto: > Hi Marco, > > > You can use sum() to add up values inside repeats. You just need to add a step inside your repeat to make sure a value is never empty (depending on your case, you can either use a default of 0 or use an if() statement to do this). See https://groups.google.com/forum/#!topic/formhub-users/xrOv7wcLf7o and this XLS Form. > > > P.S. This question would be the for the ODK Community forum (not the developers forum). > > > Cheers, > Martijn > > On Thursday, January 9, 2014 6:45:13 AM UTC-7, ma.g...@gmail.com wrote:I'm trying to understand if it's possible to make calculations across repeats (not inside that's working perfectly). > In example, in every group I put inside the calculation of the (sub)total cost, calculated by multiplicating "Unit No." and "Unit Price". > Once the enumerator has compiled all the repeats, I'd like to have a calculated field where I display the Grand Total, given by the sum of each single (sub)total. > Is it possible to implement in ODKCollect-JavaROSA? > And if it's also possible to use multiplication instead of the sum operations? > I attach an example form in excel I'm trying to implement for demo purpose. > Thanks > Marco

Hi Martin, sorry to come again on this question.

Let me explain better the situation:
We have got a mobile application based on ODK, that has been modifyed almost 2 years ago when ODK was not yet so developed as of today.
Now the behaviour is mainly the same of ODK today, except that the calculation of fields acroos repeats doesn't work, and something crash in javarosa lib.

I've downloaded the newest version of ODK, and I've seen that you have a javarosa lib modified on sep-2013, so recently modified, compared to the official javarosa that seems to be freezed in 2011.

Where can I get the sources of the javarosa lib you're using in ODK 1.4 to understand what wrong with mine?

(I hope now my question belongs to this group)

Many many thanks!

Marco

··· Il giorno venerdì 10 gennaio 2014 01:33:02 UTC+1, Martijn van de Rijdt ha scritto: > Hi Marco, > > > You can use sum() to add up values inside repeats. You just need to add a step inside your repeat to make sure a value is never empty (depending on your case, you can either use a default of 0 or use an if() statement to do this). See https://groups.google.com/forum/#!topic/formhub-users/xrOv7wcLf7o and this XLS Form. > > > P.S. This question would be the for the ODK Community forum (not the developers forum). > > > Cheers, > Martijn > > On Thursday, January 9, 2014 6:45:13 AM UTC-7, ma.g...@gmail.com wrote:I'm trying to understand if it's possible to make calculations across repeats (not inside that's working perfectly). > In example, in every group I put inside the calculation of the (sub)total cost, calculated by multiplicating "Unit No." and "Unit Price". > Once the enumerator has compiled all the repeats, I'd like to have a calculated field where I display the Grand Total, given by the sum of each single (sub)total. > Is it possible to implement in ODKCollect-JavaROSA? > And if it's also possible to use multiplication instead of the sum operations? > I attach an example form in excel I'm trying to implement for demo purpose. > Thanks > Marco

Marco,

The version of JavaRosa that is in ODK Collect can be found at
https://bitbucket.org/m.sundt/javarosa.

Yaw

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

On Wed, Jan 15, 2014 at 10:31 AM, ma.giorgi@gmail.com wrote:

Hi Martin, sorry to come again on this question.

Let me explain better the situation:
We have got a mobile application based on ODK, that has been modifyed almost 2 years ago when ODK was not yet so developed as of today.
Now the behaviour is mainly the same of ODK today, except that the calculation of fields acroos repeats doesn't work, and something crash in javarosa lib.

I've downloaded the newest version of ODK, and I've seen that you have a javarosa lib modified on sep-2013, so recently modified, compared to the official javarosa that seems to be freezed in 2011.

Where can I get the sources of the javarosa lib you're using in ODK 1.4 to understand what wrong with mine?

(I hope now my question belongs to this group)

Many many thanks!

Marco

Il giorno venerdì 10 gennaio 2014 01:33:02 UTC+1, Martijn van de Rijdt ha scritto:

Hi Marco,

You can use sum() to add up values inside repeats. You just need to add a step inside your repeat to make sure a value is never empty (depending on your case, you can either use a default of 0 or use an if() statement to do this). See https://groups.google.com/forum/#!topic/formhub-users/xrOv7wcLf7o and this XLS Form.

P.S. This question would be the for the ODK Community forum (not the developers forum).

Cheers,
Martijn

On Thursday, January 9, 2014 6:45:13 AM UTC-7, ma.g...@gmail.com wrote:I'm trying to understand if it's possible to make calculations across repeats (not inside that's working perfectly).
In example, in every group I put inside the calculation of the (sub)total cost, calculated by multiplicating "Unit No." and "Unit Price".
Once the enumerator has compiled all the repeats, I'd like to have a calculated field where I display the Grand Total, given by the sum of each single (sub)total.
Is it possible to implement in ODKCollect-JavaROSA?
And if it's also possible to use multiplication instead of the sum operations?
I attach an example form in excel I'm trying to implement for demo purpose.
Thanks
Marco

--
You received this message because you are subscribed to the Google Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com.