Skip to main content
Question

Trying to calculate difference in stock value between dates

  • November 12, 2020
  • 1 reply
  • 2 views

HI, as a newbie to PQL, I am would need help in order to calculate the different in stock levels between two months. The current display shows the SUM of the stock, with a Component Filter the particular month. How could I calculate the difference between the starting stock (January) and the current stock level, by month? (there are multiple stock items)

Thanks

Kenny7

1 reply

gabriel.okaba11
Celonaut
Forum|alt.badge.img+2
  • Celonaut
  • 229 replies
  • November 22, 2021

Hi Kenneth,

Depends whether the date and the stock are on the same table.

 

Syntax should look like the following if they exist in the same table:

 

SUM(

CASE WHEN MONTH(TABLE.MONTH) = MONTH(TODAY()) THEN TABLE.STOCK ELSE 0.0 END

)

-

SUM(

CASE WHEN MONTH(TABLE.MONTH) = 1 THEN TABLE.STOCK ELSE 0.0 END

)