5 Replies Latest reply: Aug 26, 2016 3:00 PM by Sunny Talwar Branched to a new discussion. RSS

    Peek function help

    Mark Wexelberg

      Here is my script and qvw file attached

      TEMP:

      LOAD * INLINE [

          Vendor, Date, Value

          1, 1/1/2016, 100

          1, 2/1/2016, 200

          2, 3/1/2016, 300

          2, 4/1/2016, 400

          3, 5/1/2016, 200

          4, 6/1/2016, 100

          4, 7/1/2016, 100

          5, 8/1/2016, 90

      ];

       

      Data:

      LOAD*,Peek('Value') as NextMonthValue

      Resident TEMP

      Order By Vendor, Date desc;

       

      Drop Table TEMP;

                                                                        

      Here is the result

      Vendor  Date          Value     NextMonthValue

      1          1/1/2016     100         200

      1          2/1/2016     200         -

      2          3/1/2016     300         400

      2          4/1/2016     400         100

      3          5/1/2016     200         300

      4          6/1/2016     100         500

      4          7/1/2016     500         200

      5          8/1/2016     90           100


      Here is what I want.  Grab next months value.  If Vendor has no value for next month, null.   Need to do this in the script, not expression

      Vendor  Date          Value     NextMonthValue

      1          1/1/2016     100         200

      1          2/1/2016     200         -

      2          3/1/2016     300         400

      2          4/1/2016     400         -

      3          5/1/2016     200         -

      4          6/1/2016     100         100

      4          7/1/2016     500         -

      5          8/1/2016     90           -