# If statement to return a value of the previous question

**URL:** <https://forum.dimagi.com/t/if-statement-to-return-a-value-of-the-previous-question/1173>\
**Category:** Users\
**Created:** [December 15, 2012, 2:25pm UTC](https://forum.dimagi.com/t/if-statement-to-return-a-value-of-the-previous-question/1173 "2012-12-15T14:25:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_D\_Lubambi](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@Peter\_D\_Lubambi](https://forum.dimagi.com/u/Peter_D_Lubambi)\
**Post date:** [December 15, 2012, 2:25pm UTC](https://forum.dimagi.com/t/if-statement-to-return-a-value-of-the-previous-question/1173/1 "2012-12-15T14:25:52Z")

</div>

Hi All,  
I want to use the if statement to return a value entered in previous  
question.  
if(/data/consent\_yes/breached\_position =  
'yes','/data/consent\_yes/nearest\_phcc','/data/consent\_yes/nearest\_dc\_health\_facility')

But this return the xpath it self instead of the value entered. Any  
workaround?  
Thanks.

> **···**
>
> -- Peter Dotto Lubambi, Information Technology Officer, D-tree International, Tanzania. +255 786 087 087 PPP: \*http://tz.linkedin.com/in/plubambi\*

---

<div class="post-metadata">

**Author:** ![Amelia\_Sagoff1](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@Amelia\_Sagoff1](https://forum.dimagi.com/u/Amelia_Sagoff1)\
**Post date:** [December 15, 2012, 5:44pm UTC](https://forum.dimagi.com/t/if-statement-to-return-a-value-of-the-previous-question/1173/2 "2012-12-15T17:44:32Z")

</div>

Hi Peter,

Your if is returning the literal text because you have put it inside single  
quotes. If you remove the single quotes it should return the value rather  
than the literal text.

Amelia

> **···**
>
> On Sat, Dec 15, 2012 at 2:25 PM, Peter D Lubambi wrote:
> 
> > Hi All,  
> > I want to use the if statement to return a value entered in previous  
> > question.  
> > if(/data/consent\_yes/breached\_position =  
> > 'yes','/data/consent\_yes/nearest\_phcc','/data/consent\_yes/nearest\_dc\_health\_facility')
> > 
> > ## But this return the xpath it self instead of the value entered. Any workaround? Thanks.
> > 
> > Peter Dotto Lubambi,  
> > Information Technology Officer,  
> > D-tree International,  
> > Tanzania.  
> > +255 786 087 087  
> > PPP: _[http://tz.linkedin.com/in/plubambi](http://tz.linkedin.com/in/plubambi)_
