6 Replies Latest reply: May 28, 2013 10:56 AM by Samuel Robson RSS

    Advanced Lookup Help

    Samuel Robson
      Hi Guys,
      Ive been asked to do an internet usage report using our teams proxy data . As you might imagine the data is quite diffucult to work with.
      Im stuck trying to do an advanced lookup
      Effectively i need to find the timestamp of the last time a URL was accessed. I have the following data
      When I am loading in the 4th row for Facebook i need to bring the most recent time it was accessed to do a TimeSpent column. So i need to bring up the TimeStamp column  from the 2nd row to do a comparison. Is this possible? I dont think the lookup function will work because it says it looks for the first time the data appears so it will always bring up the 1st row in the table.
      Any suggestions appreciated Many thanks

        • Re: Advanced Lookup Help


          is it the option to use order by clause in your load statement, as order by URL, TimeStamp DESC ? That way you can use lookup statement to get correct value.



            • Re: Advanced Lookup Help
              Samuel Robson



              This brings up the timestamp 10:33 or 10:30 depending on the the sort order.  This is because it is always looking for the first match and ignores the rest of the matches.


              It could work if it was possible get QV to apply the function after each row is loaded instead of over the whole table. Is this possible?

                • Re: Advanced Lookup Help

                  With lookup in load script you can experiment by yourself, here is example how to get max timestamp with max statement (MAX_TIME column):



                  LOAD * INLINE [

                      URL1, TimeStamp1

                      Facebook, 10:20

                      Facebook, 10:30

                      Google, 11:00




                  LOAD URL1 as URL, Timestamp(TimeStamp1, 'hh:mm') as TimeStamp Resident VALUES1 order by URL1, TimeStamp1 DESC;

                  drop Table VALUES1;

                  inner join (VALUES)

                  load URL, Timestamp(Max(TimeStamp), 'hh:mm') as MAX_TIME Resident VALUES Group By URL;

              • Re: Advanced Lookup Help
                Samuel Robson

                Many thanks for your help guys, but not quite what i need. I need to reference the last timeStamp previous that a URL was accessed



                IDURLTimeStampreferenced TimeStamp (calculated Column)


                10:30 (from row 1) the most recent previous time facebook was accessed

                10:35 (From row  2) the most recent previous time google was accessed


                10.36 (from row 3) the most recent previous time google was accessed


                A lookup would work if i could change the Lookup to search up from the current record, instead of down from the top of the table


                I dont know if this is possible or not, so please let me know if you think it may not be .





                • Re: Advanced Lookup Help
                  Gysbert Wassenaar

                  See attached example.