2 Replies Latest reply: Mar 4, 2018 12:05 PM by Mikel De RSS

    Min and max dates in the script

    Mikel De

      Hello guys! I frequently use the following script to get the min and max dates from a dataset and store them as variables:

       

      MinMaxDates:
      LOAD
        MIN(Date) AS MinDate,
        MAX(Date) AS MaxDate
      RESIDENT Data;
      
      LET vMinDate = PEEK('MinDate',-1,'MinMaxDates');
      LET vMaxDate = PEEK('MaxDate',-1,'MinMaxDates');
      
      
      
      
      

       

      However, I recently stumbled across the following syntax:

       

      MinMaxDates: 
      LOAD
        MIN(FieldValue('Date', RecNo())) AS MinDate,
        MAX(FieldValue('Date', RecNo())) AS MaxDate
      AUTOGENERATE FieldValueCount('Date');
      
      LET vMinDate = Peek('MinDate',-1,'MinMaxDates');
      LET vMaxDate = Peek('MaxDate',-1,'MinMaxDates');
      
      
      
      

       

      What is the difference between both? It seems that they provide the same result. Is the second option better that the first one in any way?


      Also why there is no need to reference the table with the Date field when using FieldValue()?


      Thanks!