Calculate commission problem when commission is COGS and based on gross profit

It's common to base commission on gross margin and that's what I want to do. Commissions are commonly part of COGS, which makes perfect sense to me. However since gross margin is what the commission is based on and COGS determines gross margin, I don't see how to calculate commission as each side of the equation depends upon the other! I have a spreadsheet with all the numbers and know there must be a way to solve this! Formula below in CAPS.
Please advise.
Bryan

Not to be flip but I'd go to the Accounting department and get the components of COGS numbers (materials, direct labor, etc.) leaving out commissions (they definitively should have these numbers) then just add them together and subtract from sales to get gross margin Before Commissions and the rest is easy peasy. Of course if you're taking a math class and have to back into the numbers well that's not what we're here for .

The name is Bryan, not Flip...
I have all that. The problem is commissions are part of GM and that to calculate commissions I need GM. Recursive algebra stuff needed in an excel formula!

Originally Posted by RetiredGeek

Not to be flip but I'd go to the Accounting department and get the components of COGS numbers (materials, direct labor, etc.) leaving out commissions (they definitively should have these numbers) then just add them together and subtract from sales to get gross margin Before Commissions and the rest is easy peasy. Of course if you're taking a math class and have to back into the numbers well that's not what we're here for .

This is basically goal seeking with formulas: Looking for a commission amt that when subtracted from the difference between SALE PRICE and COGS to calculate GROSS MASRGIN equals GROSS MARGIN times 0.05

If interested, here is the algebra that shows how I arrived at the formula for commission:

Thanks again. Of course it gets more complex as the commission rate varies with amount sold across the year. For now I'm just going to implement this part of it and see how it goes. Thanks!

I do have a question about your screenshot though.
The second section saying two formulas equal GM is confusing as I don't see how the second line is true GM # commission/.5 as far as I would understand.

As they say on the "Big Bang Theory" ... "do you want to do the math?"...BBTMath2.JPG
Me not so much. I'm fine with your basic math and I can fill in the blanks on a formula I find on the internet and even turn it into an excel formula or program it into a programming language. But figuring out what the formula should be I'll leave that to the geniuses like Maud. Very Nicely Done!

Thanks again Maud,
I've integrated it into my spreadsheet and it works perfectly!
I did fail getting it to use a cell with the commission in it rather than embedded though. It calculated it differently. But I'll figure that out later!