# Concatenate returns string instead value of variable

**URL:** <https://forum.getodk.org/t/concatenate-returns-string-instead-value-of-variable/19508>\
**Category:** Support\
**Created:** [April 26, 2019, 8:21am UTC](https://forum.getodk.org/t/concatenate-returns-string-instead-value-of-variable/19508 "2019-04-26T08:21:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timba](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@Timba](https://forum.getodk.org/u/Timba)\
**Post date:** [April 26, 2019, 8:21am UTC](https://forum.getodk.org/t/concatenate-returns-string-instead-value-of-variable/19508/1 "2019-04-26T08:21:42Z")

</div>

Hi all,

When I concatenate two variables into one the result is a string instead the value of this variable:

Example:  
concat('$','{','option', ${C09}, '}')  
result is: ${option1} instead the value of ${option1}

Attached is the form which demonstrates the problem. I run this on SurveyCTO.

Many thanks in advance!

[test\_problems.xlsx](https://getodk.b-cdn.net/uploads/default/original/2X/8/88f168e1dc1300525f9d1a2d13271640d726777f.xlsx) (87.3 KB)

---

<div class="post-metadata">

**Author:** ![aurdipas](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aurdipas/32/1785_2.png) [@aurdipas](https://forum.getodk.org/u/aurdipas)\
**Post date:** [April 26, 2019, 8:57am UTC](https://forum.getodk.org/t/concatenate-returns-string-instead-value-of-variable/19508/2 "2019-04-26T08:57:12Z")

</div>

concat as you wrote it return a string that is ${option1}.  
Concat function always return a string that is the concatenation of the argument inside the parenthesis.

I think you can get the result wanted with an if instead as per the attached xls.

I think there is still an error on prob\_id1 ( I didn't understand what do you want to do with it. I just changed the value to make it convertable to xform).

[test\_problems.xlsx](https://getodk.b-cdn.net/uploads/default/original/2X/9/9a1c2ab9211c63f3ec6406619e2f00e3a228ecdb.xlsx) (87.3 KB)

---

<div class="post-metadata">

**Author:** ![Timba](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@Timba](https://forum.getodk.org/u/Timba)\
**Post date:** [April 26, 2019, 9:20am UTC](https://forum.getodk.org/t/concatenate-returns-string-instead-value-of-variable/19508/3 "2019-04-26T09:20:10Z")

</div>

Many thanks @aurdipas. The if statement works well - I tried it before as an alternative to concat but apparently did not manage well the syntax.

PS. You're right - prob\_id1 contains an error - just a mix up from a larger form - sorry for the confusion.
