# Problem with calculating a hidden value

**URL:** <https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488>\
**Category:** Users\
**Created:** [November 17, 2015, 12:45pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488 "2015-11-17T12:45:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Celine\_Gross](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/c/ecae2f/32.png) [@Celine\_Gross](https://forum.dimagi.com/u/Celine_Gross)\
**Post date:** [November 17, 2015, 12:45pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/1 "2015-11-17T12:45:22Z")

</div>

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\_monthly\_income\_from\_the\_business+  
(/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

---

<div class="post-metadata">

**Author:** ![Fiorenzo\_Conte](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@Fiorenzo\_Conte](https://forum.dimagi.com/u/Fiorenzo_Conte)\
**Post date:** [November 17, 2015, 12:51pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/2 "2015-11-17T12:51:22Z")

</div>

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\_monthly\_income\_from\_the\_business+  
> > (/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  
> > email to [commcare-users+unsubscribe@googlegroups.com](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> _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
> 
> > **[Transforming Social Impact: Data Collection Software & Digital Health...](https://www.dimagi.com/)**
> >
> > Enabling global NGOs with cutting-edge data collection software & digital health solutions. Discover how Dimagi powers impactful frontline work.

---

<div class="post-metadata">

**Author:** ![Fiorenzo\_Conte](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@Fiorenzo\_Conte](https://forum.dimagi.com/u/Fiorenzo_Conte)\
**Post date:** [November 17, 2015, 1:01pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/3 "2015-11-17T13:01:13Z")

</div>

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](mailto: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\_monthly\_income\_from\_the\_business+  
> > > (/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  
> > > email to [commcare-users+unsubscribe@googlegroups.com](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > _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/](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
> 
> > **[Transforming Social Impact: Data Collection Software & Digital Health...](https://www.dimagi.com/)**
> >
> > Enabling global NGOs with cutting-edge data collection software & digital health solutions. Discover how Dimagi powers impactful frontline work.

---

<div class="post-metadata">

**Author:** ![Celine\_Gross](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/c/ecae2f/32.png) [@Celine\_Gross](https://forum.dimagi.com/u/Celine_Gross)\
**Post date:** [November 17, 2015, 1:25pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/4 "2015-11-17T13:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fiorenzo\_Conte](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@Fiorenzo\_Conte](https://forum.dimagi.com/u/Fiorenzo_Conte)\
**Post date:** [November 17, 2015, 1:27pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/5 "2015-11-17T13:27:06Z")

</div>

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  
> > email to [commcare-users+unsubscribe@googlegroups.com](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> _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
> 
> > **[Transforming Social Impact: Data Collection Software & Digital Health...](https://www.dimagi.com/)**
> >
> > Enabling global NGOs with cutting-edge data collection software & digital health solutions. Discover how Dimagi powers impactful frontline work.

---

<div class="post-metadata">

**Author:** ![Celine\_Gross](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/c/ecae2f/32.png) [@Celine\_Gross](https://forum.dimagi.com/u/Celine_Gross)\
**Post date:** [November 17, 2015, 1:40pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/6 "2015-11-17T13:40:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Fiorenzo\_Conte](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/f/7cd45c/32.png) [@Fiorenzo\_Conte](https://forum.dimagi.com/u/Fiorenzo_Conte)\
**Post date:** [November 17, 2015, 1:43pm UTC](https://forum.dimagi.com/t/problem-with-calculating-a-hidden-value/2488/7 "2015-11-17T13:43:25Z")

</div>

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  
> > email to [commcare-users+unsubscribe@googlegroups.com](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> _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
> 
> > **[Transforming Social Impact: Data Collection Software & Digital Health...](https://www.dimagi.com/)**
> >
> > Enabling global NGOs with cutting-edge data collection software & digital health solutions. Discover how Dimagi powers impactful frontline work.
