If statement error?

Is this if statement correct?

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

Your parenthesis look OK but there is a much better way! Use a Map Transform.

A map transform is simple and easily debugged!

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

3 Likes

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.

Thanks I get it now.

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.