Tommy Coyle Posted July 7, 2020 Share Posted July 7, 2020 What is the best way to create a formula that will give me the equivalent of the Excel if function. The specific example I have is if a control valve is closed (.OP <= 0) then I want the formula to give me zero flow, other wise I want it to just give me the flow reading. So something like this in Excel IF(OP<=0,0,FLOW) Thanks for your help. Link to comment Share on other sites More sharing options...
Seeq Team Kjell Raemdonck Posted July 7, 2020 Seeq Team Share Posted July 7, 2020 (edited) Hi Tommy, The easiest way to do this in Seeq is to use a condition to define the if condition, and then splice in a new signal when your condition is true. Follow the steps below to achieve this. 1) Use the Value Search tool to find when your signal .OP <= 0 2) In Formula, enter the following: $flowsignal.splice(0.toSignal(), $conditionclosed) where $flowsignal is your Flow Rate signal, and $conditionclosed is the condition we created in Step 1. What we are doing here is splicing in a new signal we create ( 0.toSignal() ) which will equal 0 when the .OP <= condition is true. You could also write all of this into 1 Formula (combining steps 1 & 2 together) by writing the following: $conditionclosed = $OP.validValues().valueSearch(isLessThanOrEqualTo(0)) $flowsignal.splice(0.toSignal(),$conditionclosed) Please let me know if this solved your question. -Kjell Edited July 7, 2020 by Kjell Raemdonck added option to write all into 1 formula 2 1 Link to comment Share on other sites More sharing options...
Adam Georgeson Posted July 16, 2020 Share Posted July 16, 2020 (edited) What benefit does .valueSearch() provide? I've typically written it this way and see no difference of outcome $conditionclosed = $OP.validValues().isLessThanOrEqualTo(0) $flowsignal.splice(0.toSignal(),$conditionclosed) Edited July 16, 2020 by Adam Georgeson 1 Link to comment Share on other sites More sharing options...
Seeq Team Sean T Posted July 16, 2020 Seeq Team Share Posted July 16, 2020 When generating a simple value search, using operators like .isLessThan() or using the mathematical operators in formula like <,> would generally be more efficient than specifying a Value Search. The .valueSearch() operator provides aditional benefit over other operators when some condition filtering is also required as we can also specify an entry/exit grace period, and max duration, among other possible operators that can be supplied directly into the valueSearch() operator without having to use other fucntions to accomplish condition filtering. An example where .ValueSearch() would be much simpler than using .isbetween() and other condition filtering operators would be: Create capsules where $signal becomes greater than 5 kW for at least 4 seconds and ending when $signal becomes greater than 15.0 kW for at least 3 seconds. Capsules longer than 1 day are discarded. $signal.valueSearch(1d, isGreaterThan(5.0 kW), 4s, true, isGreaterThan(15.0 kW), 3s, true) 2 Link to comment Share on other sites More sharing options...
Adam Georgeson Posted July 16, 2020 Share Posted July 16, 2020 Makes sense, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now