Are you trying to do variance analysis? What variance exactly do you need to analyse?
If looking at act vs planned margin, there are two components here: volume variance (eg you sold less of higher margin products than planned, and more of lower margin product) and margin variance (products did not deliver on their margins). You will need to do these separately, not in one calculation.
Ie first, analyse volume var * margin var = total sales var (see contribution of each product)
then you can analyse margin var in % into volume and margin (here I'd rather call it price) and do it on a product level.