Problem with calculating a hidden value

Hello everyone,

I’m having trouble with a very simple hidden value, supposed to calculate a
quite simple sum. I can’t understand why it’s not working, as it is very
basic. I’m additioning different monthly incomes to have a global monthly
income. I did everything by dragging the questions into the expression
editor. Here is the expression:

/data/Income_assessment/What_is_the_monthly_income_from_the_job+
(/data/Income_assessment/Estimated_yearly_income_from_crops div 12)+
/data/Income_assessment/Estimated_monthly_income_from_livestock+
/data/Income_assessment/Estimated_monthly_other_income+
/data/Income_assessment/Estimated_monthly_income_from_other_family_members

At first, I thought that the “div 12” in the middle of the sum could be a
problem, so I calculated it separately in another hidden value and added it
then to this global monthly income value. But it still wasn’t working.

Do you see what could be the problem?

Thank you so much !

Celine

Hi Celine,

thanks for the question. What is the result you see when you say it’s not
working? Does it show blank?

You can check if in the form all those questions have a value. If any of
those question is blank (e…g monthly other income is empty) that might
throw off the sum

··· On Tue, Nov 17, 2015 at 3:45 PM, Céline Gross wrote:

Hello everyone,

I’m having trouble with a very simple hidden value, supposed to calculate
a quite simple sum. I can’t understand why it’s not working, as it is very
basic. I’m additioning different monthly incomes to have a global monthly
income. I did everything by dragging the questions into the expression
editor. Here is the expression:

/data/Income_assessment/What_is_the_monthly_income_from_the_job+
(/data/Income_assessment/Estimated_yearly_income_from_crops div 12)+
/data/Income_assessment/Estimated_monthly_income_from_livestock+
/data/Income_assessment/Estimated_monthly_other_income+
/data/Income_assessment/Estimated_monthly_income_from_other_family_members

At first, I thought that the “div 12” in the middle of the sum could be a
problem, so I calculated it separately in another hidden value and added it
then to this global monthly income value. But it still wasn’t working.

Do you see what could be the problem?

Thank you so much !

Celine

You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an

Fiorenzo Conte
Senior Project Manager
West Africa | Afrique de l’Ouest
Dimagi, Inc
m Senegal : +221 77 293 91 89 | m Kenya: +254 706 970567
s : fioreco86
http://www.dimagi.com/

and to add couple of more details:

• if any of the questions in that formula have some display conditions they
might not display and won’t have a value (causing the problem)

• if that’s the cause of the problem, you can create hidden values for each
question and have as calculation condition the following:
coalesce(question_id, 0) so that the value is 0 if the question is skipped

··· On Tue, Nov 17, 2015 at 3:51 PM, Fiorenzo Conte wrote:

Hi Celine,

thanks for the question. What is the result you see when you say it’s not
working? Does it show blank?

You can check if in the form all those questions have a value. If any of
those question is blank (e…g monthly other income is empty) that might
throw off the sum

On Tue, Nov 17, 2015 at 3:45 PM, Céline Gross celine.m.gross@gmail.com wrote:

Hello everyone,

I’m having trouble with a very simple hidden value, supposed to calculate
a quite simple sum. I can’t understand why it’s not working, as it is very
basic. I’m additioning different monthly incomes to have a global monthly
income. I did everything by dragging the questions into the expression
editor. Here is the expression:

/data/Income_assessment/What_is_the_monthly_income_from_the_job+
(/data/Income_assessment/Estimated_yearly_income_from_crops div 12)+
/data/Income_assessment/Estimated_monthly_income_from_livestock+
/data/Income_assessment/Estimated_monthly_other_income+
/data/Income_assessment/Estimated_monthly_income_from_other_family_members

At first, I thought that the “div 12” in the middle of the sum could be a
problem, so I calculated it separately in another hidden value and added it
then to this global monthly income value. But it still wasn’t working.

Do you see what could be the problem?

Thank you so much !

Celine

You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an

Fiorenzo Conte
Senior Project Manager
West Africa | Afrique de l’Ouest
Dimagi, Inc
m Senegal : +221 77 293 91 89 | m Kenya: +254 706 970567
s : fioreco86
http://www.dimagi.com/

Fiorenzo Conte
Senior Project Manager
West Africa | Afrique de l’Ouest
Dimagi, Inc
m Senegal : +221 77 293 91 89 | m Kenya: +254 706 970567
s : fioreco86
http://www.dimagi.com/

Hi Fiorenzo,

Yes, the questions have display conditions so some of them are always
empty, thank you for the explanation! The result is blank, indeed.

I didn’t understand how to use this “coalesce” formula. Tell me if this is
correct: once I have created a hidden value for each question, I create a
sum like this :
coalesce(hidden_job_income, 0) + coalesce(hidden_business_income, 0) +
coalesce(hidden_farm_income, 0) + … ?
Or is it something else?

Thank you!
Céline

yup that should work

··· On Tue, Nov 17, 2015 at 4:25 PM, Céline Gross wrote:

Hi Fiorenzo,

Yes, the questions have display conditions so some of them are always
empty, thank you for the explanation! The result is blank, indeed.

I didn’t understand how to use this “coalesce” formula. Tell me if this is
correct: once I have created a hidden value for each question, I create a
sum like this :
coalesce(hidden_job_income, 0) + coalesce(hidden_business_income, 0) +
coalesce(hidden_farm_income, 0) + … ?
Or is it something else?

Thank you!
Céline

You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an

Fiorenzo Conte
Senior Project Manager
West Africa | Afrique de l’Ouest
Dimagi, Inc
m Senegal : +221 77 293 91 89 | m Kenya: +254 706 970567
s : fioreco86
http://www.dimagi.com/

Okay thank you! And just to understand, what is the advantage of the hidden
values compared to doing this :
coalesce(question 1, 0) + coalesce(question 2, 0) +… etc. without the
hidden values?

same thing, no specific advantage (coalesce is probably easier/more elegant)

··· On Tue, Nov 17, 2015 at 4:40 PM, Céline Gross wrote:

Okay thank you! And just to understand, what is the advantage of the
hidden values compared to doing this :
coalesce(question 1, 0) + coalesce(question 2, 0) +… etc. without the
hidden values?

You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an