Doing calculations based on the selections in Matrix