Jump to content

EXCEL IF(x,y1,y2)


Recommended Posts

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

  • Seeq Team

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 by Kjell Raemdonck
added option to write all into 1 formula
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

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 by Adam Georgeson
  • Like 1
Link to comment
Share on other sites

  • Seeq Team

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)
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...