Hi Wilson,
1. In on-enter event of 5 or 6th column you have to write code to do your calculations.
2. Yes you can display no of columns based on conditions. To do so create one attribute of type WDUI_VISIBILITY and bind this with your 5th column which you want to display based on condtion.
IF flag = x, set this attribute to invisible and for Y set to visible.
Cheers,
Kris..