Jump to content

Using Conditions and the Splice Function to Replace "if" Statements

Morgan Bowling

Recommended Posts

  • Seeq Team

We often do calculations where we are interested in having one result if one condition is true and a second result if another condition is true.  In this post we will discuss how to do this calculation in Seeq. 

We will create a new single signal which runs different calculations during different periods of time. This technique can be used to replicate "if" logic or "if / else" logic currently being used in excel.

Example existing code from excel or other systems

  • IF Temperature > 90 then show a result of  (Temperature * 100) 
  • IF Temperature < 90F then show a result of  (Temperature + 10)

Step 1: Identify two modes of operation



  • In the Tools tab identify the following conditions using the Value Search tool:



Step 2: Use formula to reconstruct "if/then statement" using Seeq's Splice Tool

Local Variables:

$Temperature Temperature Signal
$HighTempCondition Greater than 90 Condition

Seeq Formula:

$HighTempCalc = $Temperature * 100
$LowTempCalc = $Temperature + 10

Section 1  -  $HighTempCalc
This is a local variable which is to be run during periods of high temperature

Section 2  -  $LowTempCalc
This is a local variable which is to be run when NOT in periods of high temperature

Final  -  $LowTempCalc.splice($HighTempCalc,$HighTempCondition)
Combine your two series. Use the LowTempCalc series, unless you are in the High Temperature condition, in which case use the HighTempCalc 
Content Verified DEC2023
Edited by Rupesh Parbhoo
Updated images, corrected language on local variables in formula.
  • Like 2
Link to comment
Share on other sites

  • 1 year later...

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...