7 Replies Latest reply: Aug 28, 2016 4:46 AM by Anil Babu Branched from an earlier discussion. RSS

    Re: Peek function help

    Anil Babu

       

       

      I have one small question, Peek(value) returns

       

      returns the value of Value in the previous record read ( equivalent to previous(value) ).

       

      Let's Assume

       

      Name     Value

      A               10

      B               20

      C               30

      D               40

      E               50

       

      If we take, Peek(Value) as Value1, Then how result is visible?

       

      Name     Value        Values

      A               10      

      B               20

      C               30

      D               40

      E               50

        • Re: Peek function help
          Toni Kautto

          Anil, I branched this to a separate thread since it is not a question related directly to the thread where you posted it.

           

          I do not completely understand you question. Can you please provide a sample QVW file where Peek() returns unexpected values?

           

          It is incorrect that Peek() and Previous() are equivalent functions. Please review the definitions in help, Peek ‒ QlikView and Previous ‒ QlikView, and consider the difference by for example applying the functions on your sample data.

           

          LOAD
            *,
            Peek(Value) AS PeekValue,
            Previous(Value) AS PrevValue
          Inline [Name, Value
          A, 10
          B, 20
          C, 30
          D, 40
          E, 50]
          Where Name <> 'C';
          
            • Re: Peek function help
              Anil Babu

              Thanks,

               

              I want to know how values are coming for value1 while using peek from my table?

                • Re: Peek function help
                  Toni Kautto

                  I would suggest that you load the example script I added above. Then read the help pages, and reflect on what the example show you. Let me know if a result in that example does not make sense for you.

                   

                  If you have an other example where the result do not turn up as you expected, please attach it so that we can explain why the result look the way they do.

                    • Re: Peek function help
                      Anil Babu

                      Toni, First of all thanks.

                       

                      Capture.PNG

                       

                      For peek, It takes previous. But, I didn't understand why 30 will come?

                        • Re: Peek function help
                          Thirumala Dandamudi

                          Previous() operates on the Input to the Load statement, whereas Peek() operates on the Output of the Load statement. That is the reason you are getting 30.

                          • Re: Peek function help
                            Toni Kautto

                            There is a significant difference in the way Peek() and Previous() works.

                             

                            Peek() is used to get a value from a in memory table, meaning data that has been processed and stored in the in-memory table. It can fetch the previous row stored, it can fetch data from any cell in any in-memory table.

                            Previous() is used to get a value from the record provided from the data source. 

                             

                            In my example Name C is not loaded into memory. The record is still fetched from the data source. For Name D the previous record is Name C, and its value is 30. The conclusion of this is that you need to chose the correct function depending on what you intention is. Are you looking for a value that has been stored, or are you looking for a value from previous incoming record?