3 Replies Latest reply: May 26, 2013 6:28 AM by mika_d82 RSS

    Set Analysis previous week

      Hi everybody,


      Currently im using the following function when in need to compare between selected dates and the same dates in the previous month.


      sum({$<t_Date={">=$(=AddMonths(min(t_Date),-1)) <=$(=AddMonths(max(t_Date),-1))"}>}Clicks



      Now, i need also to compare selected  week days to previous week.


      Appreciate any help or tip



        • Re: Set Analysis previous week
          Stefan Wühl

          You can try just subtracting 7 days from your min and max dates to retrieve the dates from the prev. week:


          =sum({$<t_Date = {">=$(=Date(min(t_Date)-7))<=$(=Date(max(t_Date)-7))"}>} Clicks)


          assuming that t_Date is formatted like your standard DateFormat set in the script (otherwise use a format string with the Date() functions).


          Both above expression and your set expression for prev. month will not neccesarily return the same dates in the prev month (compared with your selected dates), because you are using an advanced search with a range (i.e. using a lower and upper limit), so if you select say two dates only, May 10th and May 15th, the set expression will return 6 dates.


          Hope this helps,


          • Re: Set Analysis previous week
            Miguel Angel Baeyens de Arce

            Hi Mika,


            Your expression is really close you what you want to achieve:


            sum({< t_Date = {">=$(=Min(t_Date -7))<=$(=Max(t_Date -7))"}>} Clicks)


            So you are substracting 7 days to the min date selected and another 7 to the max selected, meaning the previous seven days. Is that OK?


            Hope that helps.



            • Re: Set Analysis previous week



              Actually both of the suggestions worked


              Thanks a lot !