1 Reply Latest reply on Dec 2, 2016 12:17 AM by Amit Narkar

    If Else if case: Get the last non-zero value in a partition

    Anna Leveriza

      Hi!

       

      I am hoping to compute discount using last price of the previous quarter or the first asp as the beginning price. My concept would be:

       

      Discount = Trxn ASP - Base ASP

       

      Notes:

      Base ASP should all have values since there should always be either first or last asp to use and deduct with trxn asp.

       

      ***I think I should tweak the formula in red font under base asp in order for this to be possible but I can't think of what it should be. Please help. Thanks

       

        • 1. Re: If Else if case: Get the last non-zero value in a partition
          Amit Narkar

          Hi Anna,

           

          Here is my version

           

          First I calculated Base ASP as 

          if [First ASP]<>0 then [First ASP]

          elseif [Last ASP]<>0 then [Last ASP]

          elseif [First ASP]=0 AND [Last ASP]=0

          then 99999    -----trying to distinguish for later use

          end

           

          The based on earlier logic will fix all records 99999 to show previous Base ASP

           

          if attr([Base ASP])<>99999 then attr([Base ASP] )

          ELSE

          (previous_value(attr([Base ASP]))) end

           

          This is how it appears at my end.

          Base ASP.png

          1 of 1 people found this helpful