book
Article ID: KB0070296
calendar_today
Updated On:
Description
If you want to calculate the difference between two rows (a row and its next row) and have the result in a calculated column, then follow the below steps.
Resolution
To achieve the goal, you can make use of the OVER functionality in Spotfire client:
1) Below is the screen-shot of the original data table.

2). Go to Insert Menu >> Calculated Column. Use the expression -> Sum([Sales]) OVER ([Customer_Name]) - Sum([Sales]) OVER (Next([Customer_Name])) .
Below is the screen-shot of the final table.

Note that a sample analysis file "Difference.dxp" has been attached to this Knowledge Base article.
Issue/Introduction
This article shows how to use an OVER expression, and the Next option, to subtract the current row data from the next row in a calculated column in Spotfire.