Evaluate Expression Steps
  • 26 May 2021
  • 5 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Evaluate Expression Steps

  • Dark
    Light

Article summary

Overview

There are two expression steps; Evaluate Expression and Evaluate Dynamic Expression. The Evaluate Expression step is used to solve a defined algebraic expression. The step achieves this by automatically creating inputs for characters used to represent the numeric variables in the Expression. This can be helpful for people that work in fields such as banking or engineering, where they may need to evaluate a custom formula with data values from another step. The first example below demonstrates how to utilize an Evaluate Expression step to calculate the average of three test scores; the first exam, the midterm, and the final. The second example demonstrates how to utilize NCalc expressions in conjunction with an Evaluate Dynamic Expression step, to run a calculation.


Difference in Evaluate Expression and Evaluate Dynamic Expression Steps

The differences in the two evaluate expression steps lie in the different input mapping; the calculation code is the same for both. The Evaluate Expression step takes in the Expression solely as a constant. The Evaluate Dynamic Expression step allows for more dynamic mapping.

Evaluate Expression MappingEvaluate Dynamic Expression Mapping

Expression List

The chart below is a list of expressions that can be used in the Evaluate Expression and Evaluate Dynamic Expression steps to perform NCalc Functions. NCalc functions populate this list.

Additional Information
For additional information on NCalc expressions, see: NCalc.


NAMEDESCRIPTIONUSAGERESULT
AbsReturns the absolute value of a specified number.Abs(-1)1M
AcosReturns the angle whose cosine is the specified number.Acos(1)0d
AsinReturns the angle whose sine is the specified number.Asin(000d
AtanReturns the angle whose tangent is the specified number.Atan(0)0d
CeilingReturns the smallest integer greater than or equal to the specified number.Ceiling(1.5)2d
CosReturns the cosine of the specified angle.Cos(0)1d
ExpReturns e raised to the specified power.Exp(0)1d
FloorReturns the largest integer less than or equal to the specified number.Floor(1.5)1d
IEEERemainderReturns the remainder resulting from the division of a specified number by another specified number.IEEERemainder(3, 2)-1d
LogReturns the logarithm of a specified number.Log(1, 10)0d
Log10Returns the base 10 logarithm of a specified number.Log10(1)0d
MaxReturns the larger of two specified numbers.Max(1, 2)2
MinReturns the smaller of two numbers.Min(1, 2)1
PowReturns a specified number raised to the specified power.Pow(3, 2)9d
SignReturns a value indicating the sign of a number.Sign(-10)-1
SinReturns the sine of the specified angle.Sin(0)0d
SqrtReturns the square root of a specified number.Sqrt(4)2d
TanReturns the tangent of the specified angle.Tan(0)0d
TruncateCalculates the integral part of a number.Truncate(1.7)1
InReturns whether an element is in a set of values.in(1 + 1, 1, 2, 3)true
IfReturns a value based on a condition.if(3 % 2 = 1, 'value is true', 'value is false')'value is true'

Example A: Evaluate Expression

This example takes in user-defined values for each test value and averages them out using the Evaluate Expression step. 

From a Designer Folder, select the Create Flow button from the bottom action bar. Select the default template and provide a name for the Flow, then select Create.


From the Steps panel, navigate to Data > Numbers and click and drag the Evaluate Expression step into the workspace; then, connect it to the Done path of the Start step.

Next, begin setting up the Expression. From the Properties tab of the Evaluate Expression step, input the following into the Expression box: (x+y+z)/3); this configuration will evaluate the sum of three variables and divide that sum by three.  Afterward, connect the Done path of the step to the End step.


Next, add a Show Form step before the Evaluate Expression step and select Pick or Create Form from the Properties tab.

Name the Form, then select Create.  


Begin creating the Form by dragging in a Button component from the Form Components tab and naming it "Submit".  

Then, navigate to Form Components > Data and add three Number Box components on the right side of the Form; these will act as inputs for each test score.  Name each Number box after the corresponding test.

Then, add a label for each test score. 

While adding each Number Box component and naming them, press Shift+Ctl+Enter on the keyboard to add a label to the left of that component.


After adding each input component, Save and Close the Form Designer to return to the Flow Designer.

Upon returning to the Flow Designer, attach the Submit path from the Form step to the Evaluate Expression step.


Next, select the Evaluate Expression step and map the test score outputs to their corresponding variable input via Select From Flow mapping.



Debug

After configuring the Inputs for the Evaluate Expression step, Debug the flow by selecting the 'Debug' button from the top toolbar of the Flow Designer.

Debug the Flow by inputting values for each test score and clicking Submit.


Next, right-click the Evaluate Expression step, then left-click the Execution and select View Input/Output Data.

The Data will show the three test score values as Inputs and the average of the 3 as the Output value. 


Example B: Evaluate Dynamic Expression 

The following example demonstrates how to use a Create Data with an Evaluate Dynamic Expression step to solve an algebraic expression. 

  1. From a Designer Folder, select CREATE FLOW from the Global Action Bar, and CREATE a new Flow
  2. From the Flow Designer, attach a Create Data step from the FAVORITE STEPS category of the Steps tab, to the Start step.
  3. From the Properties tab of the Create Data step, under DATA > Data to Create, and select the Show Editor link. 
  4. From the Data Definitions window, Name the data "Expression" and select String from the Type dropdown. Under Input, by utilizing NCalc expressions (see the chart above), map an algebraic expression. Then click CLOSE to save the value and close the window.
    Mapping an Expression
    When defining an algebraic expression, NCalc expressions can be used in a similar manner to how they are typically used on a scientific or graphing calculator.

    For this example, define the Expression as "(Sqrt(2+2))*10". In this case, the utilized NCalc expression, "Sqrt" is used to calculate the square root of the value in the parentheses. 

  5. From Steps > Data > Numbers, attach an Evaluate Dynamic Expression step to the Done path of the Create Data step. Then connect the Done path of the Evaluate Dynamic Expression step to the End step.

  6. From the Evaluate Dynamic Expression step's Properties, Select From Flow map Expression to its respective Input

    Additional Info on Mapping Options
    By using an Evaluate Dynamic Expression step, users have the option to source the Expression Input in multiple dynamic ways. These ways include, Constant, Null, Ignore, Run Converter, Merge HTML Text, and Merge Plain Text options. This differs from being limited to only being able to define the Expression via Constant mapping. 


  7. Save the Flow, then if desired, Close the Flow Designer. 


Debug

  1. From the Flow Designer, select the Debug link from the top Action bar. Click FULL. 
    Expression Evaluation
    Upon running the Flow, the Evaluate Dynamic Expression step calculates the outcome of the Dynamic Expression. The step accomplishes this by checking any evaluating any utilized NCalc expressions and solving the equation via standard algebraic order of operations. 

  2. After the Flow runs, select Evaluate Dynamic Expression 1 > Execution 1 > View Input/Output; verify that the step properly solved the Expression. 



Was this article helpful?