# Conditional statements within expressions

**URL:** https://community.linx.software/community/t/conditional-statements-within-expressions/515
**Category:** How To
**Created:** [February 4, 2021, 12:13pm UTC](https://community.linx.software/community/t/conditional-statements-within-expressions/515 "2021-02-04T12:13:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ronan](https://community.linx.software/community/user_avatar/community.linx.software/ronan/32/433_2.png) [@ronan](https://community.linx.software/community/u/ronan)
#### Post date: [February 4, 2021, 12:13pm UTC](https://community.linx.software/community/t/conditional-statements-within-expressions/515/1 "2021-02-04T12:13:40Z")

</div>

In Linx, when making decisions to set values, you typically use a [IfElseFNC](https://linx.software/docs/reference/plugins/linx/content/ifelse) to create a condition and then using a [SetValueFNC](https://linx.software/docs/reference/plugins/linx/content/setvalue) you set the value appropriately.

Lets use the example of deciding whether or not an integer is greater than zero, if it is then a string type will be set to “Positive” and if not the type will be set to the text “Negative”.

You can achieve the above result by using the below approach:

 ![image](https://community.linx.software/community/uploads/default/original/2X/4/441a142987ca3a837521b52be0f634fa522b3996.png)

However, you are also able to create a condition exactly like the IfElse, except you can do straight in the expression editor.

A conditional statement in a Linx expression takes the following structure:

```auto
{condition to evaluate to a boolean type} ? {value if true} : {value if false}

```

The character **?** indicates the end of the condition and the start of the ‘if true’ statement. The **:** character indicates the start of the ‘else’ statement.

So in our case, we can use the below expression to set the initial value of ‘MyMessage’:

```auto
= MyNumber > 0 ? "Positive" : "Negative"

```

![image](https://community.linx.software/community/uploads/default/original/2X/6/67323833dd3e816015fb2f9c6777cde944e3cd2a.png)

 ![image](https://community.linx.software/community/uploads/default/original/2X/7/7991d6c3fb7d30118455f0927873b4b54f9d8b5c.png)

You are even able to nest conditions.

Lets add another condition that executes if the first condition is false, this nested condition will check if the number is equal (`==`) to 0, if so then the text “Neutral” will be the result, if not the the word “Negative”.

```auto
{condition1} ? {value if condition1 true} : {condition2} ? {value if condition2 is true} : {value if condition2 is false} 

```

To demonstrate, lets check if the number is 0 and set the value as “Neutral”:  
 ![image](https://community.linx.software/community/uploads/default/original/2X/3/35cb856ea2fa21259555c7acfa6ed781de1d006e.png)

This approach is very useful when setting or evaluating individual values that you don’t need to execute specific function logic for.
