I'm wondering if you may be able to use the SIZE() function to determine which condition you are in.
In the attached example, the Size starts off as 2, but when Product is added, it goes to 26.
If your initial condition has a unique size number, then your conditional can just be:
IF [SizeField]=2 THEN avg([Budget Margin])*100
ELSE SUM([Budget Margin])
212423sample.twbx 361.1 KB