LAE

 View Only
  • 1.  Date difference between two rows (current and previous), data in different columns

    Employee
    Posted 03-19-2019 00:10

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: MariaB

    Hi!

    I'm trying to create a graph where I to check the difference between to consecutive periods and identify potential errors.
    The idea is that the formula calculates the date difference between the Start Date of the current row minus the End Date of the previous row ( IF (�Start Date� � �End Date_previous row�) = �1� then �Normal� else �Abnormal�)

    2019-03-19_Calcs.xlsm - Excel.png


    How can I do this with nodes and BrainScript in lavastorm?

    Thanks a lot in advance!
    Maria


  • 2.  RE: Date difference between two rows (current and previous), data in different columns

    Employee
    Posted 03-19-2019 06:13

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: awilliams1024

    Hi Maria,
    this should do what you want:

    node:Test_Data
    bretype:core::Static Data
    editor:Label=Test Data
    editor:sortkey=5c90e6226a6a5148
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    Start Date:date,End Date:date
    1987-7-13,1988-04-10
    1988-04-11,1988-04-12
    1988-04-14,1988-06-21
    1988-06-22,1089-04-09
    EOX
    editor:XY=270,100
    end:Test_Data
    
    node:Filter
    bretype:core::Filter
    editor:sortkey=5c90e76a14a01edc
    input:@40fd2c74167f1ca2/=Test_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    if firstExec then {
    	previous_End_Date = dateAdjust('Start Date',-1,"days")
    } 
    
    date_Difference = dateSubtract('Start Date', previous_End_Date)
    
    if date_Difference == 1 then {
    	date_Interval = "Normal"
    } else {
    	date_Interval = "Abnormal"
    }
    
    emit *, date_Interval as "Date between Adjacent Periods"
    ## debug fields
    #emit previous_End_Date, date_Difference
    
    previous_End_Date = 'End Date'
    
    EOX
    editor:XY=410,100
    end:Filter


  • 3.  RE: Date difference between two rows (current and previous), data in different columns

    Employee
    Posted 03-19-2019 15:54

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: MariaB

    Thanks so much! Working perfectly