It would be easier to help if you posted some example data and the expected results, as described here.