In your database Sales are accumulated values YTD and costs are monthy values ?
The difference to be calculated is over accumulated values or monthly values ?
- Pablo Labbe
@Vision Gestão & Tecnologia
Then you need to accumulate costs. The best is to do this calculation at script level. Using the solution posed by Matthew, but accumulating Costs.
You ca use the peek and rangesum command to do this. Check this post http://community.qlik.com/message/110458 where Miguel Angel Baeyens explains how to do this.
In your load script when looking at the Sales data na dassuming its in calendar order try the following:
Sales as Sales_Cummulative,
Sales-previous(Sales) as Sales_This_Month
That should give you a month by month Sales value as well as the running cumulative total thus enabling a simple Sales_This_Month - Costs expression in your chart.
Of course you can always use the previous() function in a Straight Table to achieve the same effect.
Hope that helps,
Matt - Visual Analytics Ltd