Create Tag expression that ignores disabled points

I would like to create a simple add and divide expression however if any of the tags fail or are disabled the expression is Null, additionally the divide value would decrease the expression below the true value.
How can i create an expression without the point failing?

I would say it depends on the expression and which tags are failing/disabled. In some cases you can use coalesce() to force a 0 or another value if the tag returns a Null. Where you mentioned dividing though, you would have to make sure it can’t create a divide by 0 situation. As for the divide going below the true value, without knowing exactly what your trying to do I can’t really say. It may mean putting in some extra logic to account for if the value goes below a set value.

You could use
//verify all tags are “good”
if( isgood(tag1) and isgood(tag2) ,
[do math here] ,
//if both tags aren’t “good”, insert your fault handler:
[execute fault handler] )

What I would like to do is create an average temp from 10 probes, my expression is currently (1+2…+10 / 10) however if one probe fails then the whole expression fails or if I disable the probe it fails additionally if one probe faults and send a zero then the average temp is lower than the true value because the way the expression is written, so I’d like to know if there is a method that would ignore the disabled probes and not alter reduce the value because of the division

Have you looked at using the mean() expression function? I don’t have a spot to test it out right now but it states that it will ignore values that return as null so it may do what you want without having to get complicated in the expression to handle null values.

if that doesn’t work then I think it starts to get complicated. I’d end up trying something like:


I’d make a separate tag expression for each probe This way, you can see the result of each component going into the mean function. For such things, I like to use a raw value folder and a calculated value folder.

For each probe:

if(	isGood({[.]Raw Values/Probe 1}),
	{[.]Raw Values/Probe 1},

And for the mean:

mean(	{[.]Calculated Values/Probe 1},
		{[.]Calculated Values/Probe 2},
		{[.]Calculated Values/Probe 3},
		{[.]Calculated Values/Probe 4},
		{[.]Calculated Values/Probe 5}

Hi jordan, this worked perfectly thanks!

1 Like