I want to create a flag of some sort to be able to count totals of the code type either by ID or overall. For example: ID 1 I would want a total of $250 for red, $120 for green and $50 for blue. Overall, I would want a total of $251 for red, $290 for green, $53 for blue, and $30 for yellow.
Finally, I want to be able to exclude flags. So for example, if I wanted to include IDs that had red and exclude IDs that had a yellow associated with it, I'd exclude all of the values for ID 2, and only total the sums for ID 1 and 3, giving me a total of $251 for red, $120 for green and $50 for blue . Any suggestions would be appreciated.