Dinakar,this is very much possible.As far as i understand you need to create a variable on difference which must be a keyfigure.
You need to create a condition.There you may choose the keyfigure on which you need a variable--Operator will be equal to--Then select variable entry--Create a new variable--Variable will be of type formula and in dimension choose number.
For complete walk through you can refer the below document.
Hope this helps.
Regards,
AL