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.  Obtain a value from the last record

    Employee
    Posted 05-29-2013 20:41

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

    Originally posted by: Borg_species5618

    I am very new to Lava so please forgive me.

    I have the following table

    Month Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 YTD
    Jul-12 707.62 -229.35 466.22 232.58 -450.72 726.34 726.34
    Aug-12 705.76 -228.65 477.75 229.35 -466.22 718.00 1,444.35
    Sep-12 704.06 -$237.01 $456.94 $228.65 -$477.75 674.88 2,119.22
    Oct-12 720.35 -235.10 502.47 237.01 -456.94 767.79 2,887.02
    Nov-12 701.82 -226.01 534.22 235.10 -502.47 742.65 3,629.67
    Dec-12 756.27 -235.95 488.77 226.01 -534.22 700.89 4,330.56
    Jan-13 755.82 -239.24 519.74 235.95 -488.77 783.49 5,114.05
    Feb-13 671.56 -209.84 547.76 239.24 -519.74 728.97 5,843.02
    Mar-13 807.42 -240.73 514.67 209.84 -547.76 743.45 6,586.47
    Apr-13 752.07 -250.32 492.48 240.73 -514.67 720.29 7,306.76


    With this input table I am only interested in the value of section 2 contained in the record with the latest date.

    I have sorted the data by month, thus ensuring the value I require will always be in the last record

    Tried to search this forum and could not find an answer .
    Hope someone can help

    Thankyou

    Frank


  • 2.  RE: Obtain a value from the last record

    Employee
    Posted 05-29-2013 20:56

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

    Originally posted by: pdespot

    Hi, Frank.

    There are a couple of ways to do this. The first way is using the Agg Ex node. Simply wire that node to the output of your sort, set the "Group By" parameter to 1, and the script to:
    emit 'Section 2' where lastInGroup

    The "Group By" of 1 tells the node that all the records are 1 group. The "emit 'Section 2' part of the script tells it to output the field called 'Section 2' (you can specify multiple fields by just separating them with commas). Finally, the "where lastInGroup" tells the node to only emit when the built in lastInGroup variable is true. As the name implies, it will only be true when you get to the last member of the group.

    Another way to accomplish the same thing is with the Tail node. That node will let you specify the last X records to output. Then you can use a filter node to just emit the column you want.

    Hope this helps.

    -Pavel


  • 3.  RE: Obtain a value from the last record

    Employee
    Posted 05-29-2013 22:22

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

    Originally posted by: Borg_species5618

    thankyou Pavel, Tried your first answer and it worked perfectly, I was using the Agg node by mistake...not sure how I can flag this question as answered and give you a +1...