(sum(case when {accounttype} = 'Income' then {gros...
# general
m
(sum(case when {accounttype} = 'Income' then {grossamount} else 0 end) - sum(case when {accounttype} = 'Cost of Goods Sold' then {grossamount} else 0 end)) / sum(case when {accounttype} = 'Income' then {grossamount} else 0 end)