# Usage of IF Statement

**URL:** <https://forum.cloverdx.com/t/usage-of-if-statement/1148>\
**Category:** CloverDX Platform\
**Created:** [December 25, 2012, 12:00am UTC](https://forum.cloverdx.com/t/usage-of-if-statement/1148 "2012-12-25T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhil](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/akhil/32/106_2.png) [@akhil](https://forum.cloverdx.com/u/akhil)\
**Post date:** [December 25, 2012, 12:00am UTC](https://forum.cloverdx.com/t/usage-of-if-statement/1148/1 "2012-12-25T00:00:00Z")

</div>

In the reformat component, I have created a expression as follows. But its giving a syntax error.

if isnull($in.0.ID) $in.0.ACCOUNT\_NAME else $in.0.BILLING\_CITY

Could you please let me know how to use the if statement correctly.

Thanks & Regards,  
Akhil

---

<div class="post-metadata">

**Author:** ![David\_Hlidek](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@David\_Hlidek](https://forum.cloverdx.com/u/David_Hlidek)\
**Post date:** [December 31, 2012, 8:39am UTC](https://forum.cloverdx.com/t/usage-of-if-statement/1148/2 "2012-12-31T08:39:32Z")

</div>

Hi Akhil,

please take a look on [http://doc.cloveretl.com/documentation/ … -ctl2.html](http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/statements-ctl2.html) and [http://doc.cloveretl.com/documentation/ … -ctl2.html](http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/control-statements-ctl2.html)

In your case:

```auto
if (isnull($in.0.ID)) $in.0.ACCOUNT_NAME; else $in.0.BILLING_CITY;

```

should work. I added round brackets around condition and add semicolons for each statement. Also, you are probably missing left side of statements. So it should be something like:

```auto
if (isnull($in.0.ID)) $out.0.MY_FIELD = $in.0.ACCOUNT_NAME; else $out.0.MY_FIELD = $in.0.BILLING_CITY;

```

Or shorter:

```auto
$out.0.MY_FIELD = isnull($in.0.ID) ? $in.0.ACCOUNT_NAME : $in.0.BILLING_CITY;

```

I hope this helps.

---

<div class="post-metadata">

**Author:** ![akhil](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/akhil/32/106_2.png) [@akhil](https://forum.cloverdx.com/u/akhil)\
**Post date:** [December 31, 2012, 10:13am UTC](https://forum.cloverdx.com/t/usage-of-if-statement/1148/3 "2012-12-31T10:13:07Z")

</div>

Thanks Jaroslav.

Thanks & Regards,  
Akhil
