Calculated Field Transformation

Description

Allows a user to create new column values by applying expressions, the result can be a new defined column or it can replace the existing column value.

Configuration

To add the Calculated Field Transformation to a stream, follow the steps below:

  1. Ensure you have a use case open in the stream designer, this can be a new use case or an existing use case
  2. From the toolbox on the left expand the Transformation option and scroll down until you can see “Calculated Field Transformation”
    • You can also use the search in the header to find the stream object quickly
  3. Click and drag the Calculated Field Transformation from the toolbox onto the canvas
  4. Rename the Transformation by clicking into the text button on the action bar
  5. Save the Stream by clicking the save button in the action bar
  6. Hover over the icon for the stream object until it turns orange and then double click to open the configuration page
    • You can optionally use the configure option on the action bar once you have selected the specific stream object and then clicking this option
  7. Configuration options
    • The drop-down allows you to associate this stream object with a specific collection. The default option is derived from the default specified against the specific use case and is generated left as the same option. If you do need to change it to another collection make the change by selecting the new collection in the drop-down.
  8. Enter Editor details.
    • Click on the “+”-button to add new rows. You can use a calculated field in another calculated field’s expression using {}. Example: Col2 = {Col1} *2
    • Select Calculated Field from drop-down list
    • Enter Expression
    • Select Data Type from drop-down list
  9. Select Results Returned As from drop-down list: Append to Current or New
  10. Click Apply on the action bar, and then save the stream using the save button.
Examples

The items listed below are examples of how the Derived Column Editor can be configured to create new columns using expressions.

Strings
Create a new string using data points from the stream. Please note that you have to add a “+” sign to add the string values together.

“Request from ” + L_Country + “, ” + L_Location + ” for unit: ” + L_Name

To create a hard-coded new string value:

Demonstration Unit #A2

If-statement
Using the short-hand If-statement the following reads “If the vibration is larger than 9000 then value is High otherwise it’s Medium

R_L_Vibration > 9000 ? “High” : “Medium”

Date and Time
Current date and time

DateTime.UtcNow

Get the current date and time and adding additional days to the date:

DateTime.UtcNow.AddDays(2)

Larger than
This will return true or false. Please note that the Data Type needs to be set to Boolean.

R_L_Vibration > 9000

Limitations
  • None at this time.
Release Notes
Version: 3.14
Released: 09-Sep-2019
Release Notes: Added the ability to use one calculated field in another calculated field’s expression
Version Released Release Notes
3.13 09-Sep-2019 Fixed issues with Payload selection.
3.12 04-Sep-2019 Upgraded System.Linq.Dynamic.Core.
3.11 27-Aug-2019 Added option to specify Existing With New or only New columns as output.
3.10 19-Aug-2019 * Added validation for field identifiers.
* Added Error output when calculation fails.
3.09 21-June-2019 Change name to Calculated Field and update icon.
3.08 4-March-2019 Updated help URL.
3.07 22-May-2018 Fixed outputs that overwrite input fields not having the specified output type.
3.06 11-May-2018 Added DateTime type to list of derived output types.
3.05 10-May-2018 Fixed null-reference exceptions in GetOutputAttributes.
3.04 10-May-2018 Fixed “ToInt is not a valid method” exception.
3.03 10-May-2018 Fixed “Operator cannot be applied to operands of type Object and …” exceptions.
3.02 26-Apr-2018 Updated DLL.
3.01 19-Apr-2018 Changed Agent state to Virtual.
3.0 19-Apr-2018 Initial Release.

This is the legacy version of the XMPro Documentation site. For the latest XMPro documentation, please visit documentation.xmpro.com

X