Results 1 to 3 of 3

Thread: Date difference between two rows (current and previous), data in different columns

  1. #1

    Default Date difference between two rows (current and previous), data in different columns

    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. #2
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    244

    Default

    Hi Maria,
    this should do what you want:

    Code:
    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. #3

    Default

    Thanks so much! Working perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •