Continuing the discussion from PartTran BAQ: Calculating the "Running Total" of the History Tracker:

Create a BAQ to try to imitate the behavior of PartTranHistory. I follow the query in the post, but the running total doesn’t calculate correctly, but only in specific tran types.

This is the current return values (from right to left Running Total, Output, Input)

the query that I use to calculate this is:

```
((
CASE
WHEN PartTran.TranType IN ('ADJ-CST', 'ADJ-QTY', 'AST-STK', 'DMR-STK', 'INS-STK', 'MFG-STK', 'PLT-STK', 'PUR-STK', 'STK-STK', 'SVG-STK')
THEN 1
WHEN PartTran.TranType IN ('STK-ASM', 'STK-CUS', 'STK-INS', 'STK-KIT', 'STK-FAM', 'STK-MTL', 'STK-PLT', 'STK-STK', 'STK-UKN', 'STK-DMR', 'PLT-STK')
THEN -1
ELSE 0
END
) * PartTran.TranQty) as [Calculated_Movimiento],
(CASE WHEN Movimiento > 0 THEN Movimiento ELSE 0 END) as [Calculated_Entrada],
(CASE WHEN Movimiento < 0 THEN Movimiento ELSE 0 END) as [Calculated_Salida],
(SUM(Movimiento) OVER(PARTITION BY PartTran.PartNum, PartTran.Plant ORDER BY PartTran.TranNum)) as [Calculated_Saldo]
```

This calculation error doesn’t always appear