Multiply and adding up multiple items does not show total in the end

I have two items to select, and multiply with their respective prices,
and I need ODK collect to show the total cost of items at the end of the form.

When I get to the end of the form ODK collect should display total value,
this works fine if I selected both items, but if I skip one the grand total
comes up blank

Sounds like you just need to put each one in an if(), and set it equal to 0
if the quantity isn't entered. So you can get your item 1 total with a
calculation like:

total1: if(${quantity1} != null, ${quantity1} * ${price1}, 0)

Then you can output the result in a note at the end of the form. "Total
spent on item 1: ${total1}"

Jason

··· On Wednesday, April 9, 2014 3:32:50 AM UTC-4, akako...@gmail.com wrote: > > I have two items to select, and multiply with their respective prices, > and I need ODK collect to show the total cost of items at the end of the > form. > > When I get to the end of the form ODK collect should display total value, > this works fine if I selected both items, but if I skip one the grand total > comes up blank >

Thank you Jason,
This works fine when the questions are not put under skip logic, but with skip
logic it does not work.
I have attached the file for you to review

delivery_test.xlsx (26.8 KB)

··· On Wednesday, April 9, 2014 10:32:50 AM UTC+3, akako...@gmail.com wrote: > I have two items to select, and multiply with their respective prices, > and I need ODK collect to show the total cost of items at the end of the form. > > When I get to the end of the form ODK collect should display total value, > this works fine if I selected both items, but if I skip one the grand total > comes up blank

I removed flat=TRUE from the settings page and it seems to be working.
Hope that helps.

Can you point me to documentation of the "flat" setting? I'm not familiar
with it. I assume it has something to do with not normalizing
select-multiples or something like that, but it looks like it was messing
up your grouping.

Jason

··· On Thursday, April 10, 2014 1:55:03 PM UTC-4, akako...@gmail.com wrote: > > On Wednesday, April 9, 2014 10:32:50 AM UTC+3, akako...@gmail.com wrote: > > I have two items to select, and multiply with their respective prices, > > and I need ODK collect to show the total cost of items at the end of the > form. > > > > When I get to the end of the form ODK collect should display total value, > > this works fine if I selected both items, but if I skip one the grand > total > > comes up blank > > Thank you Jason, > This works fine when the questions are not put under skip logic, but with > skip > logic it does not work. > I have attached the file for you to review >

Oh I see what you are saying. You need to move the calculate outside of
the groups with a relevance on them. The calculate variable is not being
created if it is skipped. Move it just after the end group and it should
work.

Jason

··· On Friday, April 11, 2014 12:58:00 PM UTC-4, Jason Ives wrote: > > I removed flat=TRUE from the settings page and it seems to be working. > Hope that helps. > > Can you point me to documentation of the "flat" setting? I'm not familiar > with it. I assume it has something to do with not normalizing > select-multiples or something like that, but it looks like it was messing > up your grouping. > > Jason > > On Thursday, April 10, 2014 1:55:03 PM UTC-4, akako...@gmail.com wrote: >> >> On Wednesday, April 9, 2014 10:32:50 AM UTC+3, akako...@gmail.com wrote: >> > I have two items to select, and multiply with their respective prices, >> > and I need ODK collect to show the total cost of items at the end of >> the form. >> > >> > When I get to the end of the form ODK collect should display total >> value, >> > this works fine if I selected both items, but if I skip one the grand >> total >> > comes up blank >> >> Thank you Jason, >> This works fine when the questions are not put under skip logic, but with >> skip >> logic it does not work. >> I have attached the file for you to review >> >