4 Replies Latest reply on Dec 18, 2016 5:57 PM by Anna Leveriza

    Previous Value: Get the last value of the previous year

    Anna Leveriza

      Hi,

       

      I have a dataset and my goal is to get the last cost of the previous year as my beginning cost.

       

      I'm using the following formulas:

      First Cost = IF [Ship Date]=[First Ship Date]THEN [Min Cost] ELSE NULL End

      Last Cost = IF [Ship Date]=[Last Ship Date]THEN [Min Cost] ELSE NULL End

      Base Cost =

      IF [First Cost]<>0 THEN [First Cost]

      ELSEIF [Last Cost]<>0 THEN [Last Cost]

      ELSEIF [First Cost]=NULL AND [Last Cost]=NULL then NULL end

       

      Beg. Cost = IF ATTR([Base Cost])<>NULL then ATTR([Base Cost]) ELSE PREVIOUS_VALUE(ATTR([Base Cost]))END

      Edit Table Calculation:

      Compute Using: Addressing > Product, Date .... Sort Automatic

      At the Level: Date

      Restarting Every: Product

       

      And the result will be the beginning cost is the first cost of the year or the first base cost.

       

      What I want to happen is something like this:

       

      I think it's a matter of changing either the the Beg. Cost formula, Base Cost formula or Editing the Table Calculation but I just don't know what to tweak in order to arrive at my goal. Hope you could help. Thanks!!!

       

      Message was edited by: Anna Leveriza