3 Replies Latest reply: Aug 1, 2011 4:41 AM by Stefan Wühl RSS

    Set analysis prb


      I want to compare sales : week  Vs Week -1 and Week N Vs Week N -1

      i use :

      "=sum({$<Année = {$( =only(Année) - $(=if(only(Semaine) = 1, 1, 0)))}, Semaine = {$( =only(Semaine)-1 + $(=if(only(Semaine) = 1, 53, 0)))}>} CA_RAY)"

      For Week Vs Week -1 nut result for all week it's 0 only for week 1 this work

      but for Week N Vs N-1 it's work perfectly.

      I need your help pls!



        • Set analysis prb
          Stefan Wühl

          Hm, I don't completely understand.


          Above expression is to give you the sum of CA_RAY for week prior to selected, is this true?


          How do you calculate the expression for N vs N-1 then?


          Please note that you may only select one value in the Annee resp. Semaine fields, because only will give you NULL if you select more than one value.


          Could you post a small example app here? I think this would make things easier.



            • Set analysis prb

              Hello My probléme is resolved I used a fieled with If expression to select Année (Year) and Semaine ( Week)

              So the function Only dont work .

              Thanks for your help !


              • Expression for N Vs N-1 : sum({$<YearNumber = {$(=only(YearNumber) - 1)}>} SALES)


              • Expression for Week Vs Week -1 :

              sum({$<YearNumber = {$( =only(YearNumber) - $(=if(only(WeekNumber) = 1, 1, 0)))}, WeekNumber = {$( =only(WeekNumber)-1 + $(=if(only(WeekNumber) = 1, 53, 0)))}>} Sales)

                • Set analysis prb
                  Stefan Wühl

                  I am glad that this was of any help for you.


                  Instead of Only() you could use max() function, which will also work if you select more than one (returning the max year for example), or limit the field selection in properties to always one selected value.


                  Regarding your Week vs Week-1 calculation, it might be easier if you calculate the week difference based on date (using eg weekstart() ), this should take year change into account. There is also a weekyear() function to calculate the year a week is in.