I think if you're looking for a formula, it doesn't exist. Knowing what to do and when to do it, is all part of being a good musician.

No two songs are the same and you can't look at drum fills in isolation - you need to be aware of what the other instruments are doing and the rhythms which are involved. Then it's a case of making a judgement and playing whatever is appropriate.

As Bob (PgFantastic) said, the pros do it first time, all the time.

ROG.