(((((sum(case when {accounttype} = 'Income' then {...
# 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)) )*100