LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  incrementing a date based on criteria

    Employee
    Posted 03-23-2015 08:12

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

    Originally posted by: dhrobertson

    Hi All,

    I'm struggling with a problem that I hope someone can help me with...

    the scenario is this. I have meetings that are listed based on hours. 4 hours equates to half a day, 8 hours to a full day. the output required is not interested in hours but wants to know about the meetings in respect of half days only. I have created logic to create additional rows in order to create 2 rows for a 8 hour meeting, breaking it down into 2 half days (am/pm). my issues is around when a meeting may be split over more than 1 day. if I split 1 day it is still the same date.... when a source row specifies a meeting over 2 days however (see source input line 4 (16 hours), I need to generate 4 rows, which I can do in my logic, BUT..... my logic creates the rows with the same date (see output for the 23-09-2014).... I need to create 2 rows for the specified startdate (in this case 23-09-2014) and then add 1 day for the last 2 rows (24-09-2014). if the meeting was over 5 days it would be the same principal but over 10 rows but with 5 incrementing dates.

    I hope I have made sense in my explanation??

    brainscript below. any help would be greatly appreciated.

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=551029390db05ff0
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    startdate:date, meetingid:int,hoursworked:int
    2014-09-20,1111,4
    2014-09-21,2222,8
    2014-09-22,3333,8
    2014-09-23,4444,16
    EOX
    editor:XY=860,150
    end:Static_Data


    node:Duplicate_rows_to_create_05_day_values_3
    bretype:core::Filter
    editor:Label=Duplicate rows to create 0.5 day values
    editor:sortkey=5508476b197a264a_3
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX

    rowcounter = hoursworked / 4
    DAYVALUECALC = 0.5

    output 1
    {
    emit rowcounter
    emit hoursworked
    emit meetingid
    emit startdate
    emit "a" as DAYVALUECALC
    where false
    }

    i = 1
    while i <= rowcounter
    {

    do output 1
    {
    emit rowcounter
    emit hoursworked
    emit meetingid
    emit startdate
    emit DAYVALUECALC
    }
    i = i+1
    }


    EOX
    editor:XY=960,150
    end:Duplicate_rows_to_create_05_day_values_3


  • 2.  RE: incrementing a date based on criteria

    Employee
    Posted 03-23-2015 08:45

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

    Originally posted by: ryeh

    Try the following:

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=551029390db05ff0
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    startdate:date, meetingid:int,hoursworked:int
    2014-09-20,1111,4
    2014-09-21,2222,8
    2014-09-22,3333,12
    2014-09-23,4444,16
    2014-09-24,5555,80
    EOX
    editor:XY=180,150
    end:Static_Data

    node:Duplicate_rows_to_create_05_day_values_3
    bretype:core::Filter
    editor:Label=Duplicate rows to create 0.5 day values
    editor:sortkey=5508476b197a264a_3
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX

    rowcounter = hoursworked / 4
    DAYVALUECALC = 0.5

    output 1
    {
    emit rowcounter
    emit hoursworked
    emit meetingid
    emit startdate
    emit "a" as DAYVALUECALC
    where false
    }

    i = 1
    while i <= rowcounter
    {

    do output 1
    {
    emit rowcounter
    emit hoursworked
    emit meetingid
    emit startdate.dateAdjust(floor((i-1)/2).long(),"days") as startdate
    emit DAYVALUECALC
    }
    i = i+1
    }


    EOX
    editor:XY=280,150
    end:Duplicate_rows_to_create_05_day_values_3


  • 3.  RE: incrementing a date based on criteria

    Employee
    Posted 03-23-2015 09:24

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

    Originally posted by: dhrobertson

    thanks for the help, it certainly looks good! thank you very much.