Calculate price change from period to period


Hello all.


I'm trying to show the change in price month over month. For example, I'm trying to show that the OpProgramPrice has changed $0.01 from AccountingMonth 19-01 to 19-06. Any ideas on how to do this? See the table below.


I've already tried this case statement to have it focus on 19-06 and minus 19-01 but it isn't doing the trick. 


Any ideas?


(case when `AccountingMonth`= '19-06' then `OpProgramPrice` else 0 end) - (case when `AccountingMonth`= '19-01' then `OpProgramPrice` else 0 end)






  • rado98
    rado98 Contributor

    Not sure it will work for future peroids but I think your beastmode would work like this


    AVERAGE(   (case when `AccountingMonth`= '19-06' then `OpProgramPrice` else 0 end)   )


    AVERAGE(   (case when `AccountingMonth`= '19-01' then `OpProgramPrice` else 0 end)   )



    In order to calculate things accross rows you need an aggragating function in there