I don't have a formula but I have a few rules that I try to follow.
Analogue front end should be very strong or all will be for nothing. I believe that the table itself is the most important part of it, then the arm, then the phono and then the cartridge. Good $350 MM cartridge sounds excellent in $1500 arm and $4000 table through $1500 phono. That's what I have. One day I will upgrade the catridge and the phono, preferably at the same time and preferable to something about three times more expensive.
The speakers. I keep them for a very long time, 15-20 years, so they must be good. I don't think that there is anything under $10k that I would really like to upgrade to, so for now I keep my 17 year old speakers that used to cost $1500 new.
I buy everything used except cartridges.
So yes, as you said, whatever sounds great, taking the cost into consideration.