if you want to go with your narrow definition of g...
# general
b
if you want to go with your narrow definition of gross margin as
(sum(gross amount of income accounts) - sum(gross amount of cogs accounts)) / sum(gross amount of income accounts)
then you can use SUM