2 Replies Latest reply: Oct 4, 2018 4:06 PM by Roshan P RSS

    Challenges with peek function

    Michael Metzger

      This is my query:

      // DEMO LOAD

      ORDER:
      Load * Inline [
      Customer|Order
      101|2013
      101|2011
      102|2009
      103|2015
      101|2017
      103|2018
      ]
      (delimiter is '|');

      // THIS DOES NOT WORK

      FIRST_ORDER:
      Load Customer, Peek(Order,0) As FirstOrder
      Resident ORDER;

      // WISHED RESULT:
      //
      // Customer, FirstOrder
      // 101, 2011
      // 102, 2009
      // 103, 2015

      --------------------

       

      I expect this result for "FIRST_ORDER" shown in "WISHED RESULT", however have challenge to write the query accordingly.

        • Re: Challenges with peek function
          vamsee duggirala

          My Bad I haven't read your column Names correctly

           

          Try

           

          ORDER:
          Load * Inline [
          Customer|Order
          101|2013
          101|2011
          102|2009
          103|2015
          101|2017
          103|2018
          ]
          (delimiter is '|');

          First_Order_Map:
          Mapping LOAD
          Customer,
          Min(Order) as FirstOrder
          Resident ORDER
          Group By Customer;

          FIRST_ORDER:
          NoConcatenate
          Load

          Customer,
          ApplyMap('First_Order_Map',Customer) as FirstOrder

          Resident ORDER;
          DROP Table ORDER;

          • Re: Challenges with peek function
            Roshan P

            Try this :

            ORDER:

             

             

            Load * Inline [

             

             

            Customer|Order

             

             

            101|2013

             

             

            101|2011

             

             

            102|2009

             

             

            103|2015

             

             

            101|2017

             

             

            103|2018

             

             

            ] (delimiter is '|');

             

             

            FIRST_ORDER:

            NoConcatenate

             

             

            Load

            Customer,

            Min(Order) As FirstOrder

             

             

            Resident ORDER

            Group by Customer;

             

             

            DROP Table ORDER;