cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Advanced Tags: Nested condition formula allowed?

JaimePR
10-Marble

Advanced Tags: Nested condition formula allowed?

Hello community,
I would like to know if it's possible to create a nested condition formula using a Derived Tag in Advanced Tags in KEPServerEX. Something "Condition ? Value_if_True : Value_if_False"


The idea is to retrieve certain tag based on a tag value, for example:

plc1secuence == 1 ? plc2tag1 : plc1secuence == 2 ? plc3tag1 : -1

 


Tried using IIF statement as well but it doesn't like it either...

 

Looking forward to hear from you.


Cheers,

2 REPLIES 2

Hi, 

 

Yes, nested conditional expressions are supported in KEPServerEX Advanced Tags using the ternary operator. Your syntax just needs proper grouping using parentheses. Here's a corrected version of your logic:

 

plc1sequence == 1 ? plc2tag1 : (plc1sequence == 2 ? plc3tag1 : -1)

 

This ensures that the second condition is only evaluated when the first one is false. Avoid using IIF—it's not valid in this context. Stick with the condition ? true_value : false_value format and use parentheses to control the logic flow.

 

Thanks,

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.

Hello Shashi,
Thank you for your reply. I had tried your suggestion before but it does not like the "ternary operator expression".
Downloaded the latest version just in case this was added in newer versions but nothing (same syntax error as usual).

Tried the following dummy examples:

TAG(Channel1.Device1.TestSecuencia) == 1 ? TAG(Channel1.Device1.Test1Unidad) : TAG(Channel1.Device1.Test2Unidad)
(TAG(Channel1.Device1.TestSecuencia) == 1) ? TAG(Channel1.Device1.Test1Unidad) : TAG(Channel1.Device1.Test2Unidad)

 

The nested one (the one you described in your post - using grouping parentheses):

TAG(Channel1.Device1.TestSecuencia) == 1 ? TAG(Channel1.Device1.Test1Unidad) : (TAG(Channel1.Device1.TestSecuencia) == 2 ? TAG(Channel1.Device1.Test2Unidad) : -1)

 

All previous examples throw: "Expression invalid: Syntax error: '?'"

inline expression error.png

Currently using KEPServerEX 6.17, V6.17.269.0 (customer running older: V6.9.572.0)

Announcements


Top Tags