# If statement error?

**URL:** <https://forum.inductiveautomation.com/t/if-statement-error/65469>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 20, 2022, 3:54pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469 "2022-10-20T15:54:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 20, 2022, 3:54pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469/1 "2022-10-20T15:54:42Z")

</div>

Is this if statement correct?

```auto
if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}-1.9) <= {this.props.text},'Green',
	if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}+1.9) >= {this.props.text},'Green',
	if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}-4.9) <= {this.props.text},'Yellow',
	if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}+4.9) >= {this.props.text},'Yellow',
	if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}-5.0) <= {this.props.text},'Red',
	if(({[default]Phase 1 Extrusion/PMR2/PMR2_Residence_Time_Target}+5.0) >= {this.props.text},'Red','Red'))))))

```

assume the time\_target is 32 and the props.text is 32.9

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 20, 2022, 4:03pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469/2 "2022-10-20T16:03:03Z")

</div>

Your parenthesis look OK but there is a much better way! Use a [Map Transform](https://docs.inductiveautomation.com/display/DOC81/Map+Transform).

 ![Map transform](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/7665c72d04d253011240cf50f9fcb59998f7d71c.png)

_A map transform is simple and easily debugged!_

Pay attention to the use of `( )`, `[]`, `( ]` and `[ )` to define the bounds of each range.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 20, 2022, 4:05pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469/3 "2022-10-20T16:05:37Z")

</div>

Is there a problem with it not working correctly right now? If so I would guess its that you're doing a comparison of floats on a string object and you may need to type case `{this.props.text}` to a float.

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 20, 2022, 5:21pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469/4 "2022-10-20T17:21:16Z")

</div>

Thanks I get it now.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 20, 2022, 10:03pm UTC](https://forum.inductiveautomation.com/t/if-statement-error/65469/5 "2022-10-20T22:03:58Z")

</div>

I misunderstood the question originally. I've updated my answer.  
Don't forget to mark one of the answers as the solution. It may help someone else.
