Data360 Analyze

 View Only
  • 1.  Calculate Fields Node

    Posted 02-22-2024 01:24

    Hello everyone, a quick question.

    Do i always have to create new output columns while i use calculate fields, it would be nice to use it for conditionals?

    As an example, would it be possible to replicate the following from a transform node in Calculate fields, to have a conditional without creating a new column.:

    import datetime
     
    if in1.date1 < in1.date2:
        out1+=in1


    ------------------------------
    Henrik B
    E.ON Sverige
    ------------------------------


  • 2.  RE: Calculate Fields Node

    Employee
    Posted 02-23-2024 09:09

    What are you wanting to do with a calculate fields node?

    It looks like that example code is from a ProcessRecords property of a Transform node. So it is not the code that determines what columns to create.



    ------------------------------
    Ernest Jones
    Precisely Software Inc.
    PEARL RIVER NY
    ------------------------------



  • 3.  RE: Calculate Fields Node

    Employee
    Posted 02-27-2024 12:05

    Per the description of the node in the Help documentation:

    "Uses Python scripting to apply an expression to fields in data attached to the input node, generating new fields in your data to store the results of the calculation."

    The node was created to simplify the creation of new fields based on a simplified set of field constructs in the expression. Note that even with the Transform node, the creation of the node's output metadata is performed (by the ConfigureFields script) prior to the processing of the first record according to the logic in the ProcessRecords script. Because of this, it is not possible to used values in the input data to determine whether an output field is created by the node. the processing of a out1+=in1 statement in the ProcessRecords script will set the values of the output fields rather than manipulate the metadata.



    ------------------------------
    Adrian Williams
    Precisely Software Inc.
    ------------------------------