Hello All, what can I do to return a zero value i.e "0.00" for a null value of a ratio of (IF badval('PI_TAG_AVG') THEN "0.00" ELSE ('PITag_1'*'PITag_2')/('PITag_2'))

Hello All, what can I do to return a zero value i.e "0.00" for a null value of a ratio of (IF badval('PI_TAG_AVG') THEN "0.00" ELSE ('PITag_1'*'PITag_2')/('PITag_2'))

- 3 people found this helpful
Hello!

What product are you using? Is this in PI Asset Analytics or PI performance equations?

If I understand your question right, you want to return 0.00 whenever a bad value is encountered otherwise return the ration (1 +2) / 2?

This is one way of checking:

IF badval('PI_TAG_AVG') THEN "0.00" ELSE IF badVal(('PITag_1'*'PITag_2')/('PITag_2')) Then "0.00" ELSE ('PITag_1'*'PITag_2')/('PITag_2')

Alternatively, you could also simplify this with something like:

IF badval('PI_TAG_AVG') OR badval('PITag_1') OR badval('PITag_2') THEN "0.00" ELSE ('PITag_1'*'PITag_2')/('PITag_2')

The first option is more "correct" as it will also return 0.00 when there is an error (divide by 0 etc.) but isn't as neat (and more computations!)

Let me know if that works.

Hello!

What product are you using? Is this in PI Asset Analytics or PI performance equations?

If I understand your question right, you want to return 0.00 whenever a bad value is encountered otherwise return the ration (1 +2) / 2?

This is one way of checking:

Alternatively, you could also simplify this with something like:

The first option is more "correct" as it will also return 0.00 when there is an error (divide by 0 etc.) but isn't as neat (and more computations!)

Let me know if that works.