The other answers quote the relevant section of the Laws. It's not entirely clear from the Laws that advantage is a discretionary decision, but the following from IFAB's practical guidelines [pdf] clarifies that this is the case:
The referee may play advantage whenever an offence occurs but should
consider the following in deciding whether to apply the advantage or stop play:
- the severity of the offence – if the offence warrants a sending-off, the referee
must stop play and send off the player unless there is a clear opportunity to
score a goal
- the position where the offence was committed - the closer to the opponent’s
goal, the more effective the advantage can be
- the chances of an immediate, promising attack
- the atmosphere of the match
In your specific example, you need to simply decide whether, during the period you were attempting to play advantage, the team ends up in a better position than they would have been if the free kick had been given. Once this benefit occurs there is no going back to the free kick, regardless of whatever happens next.
For example, if a foul occurs near halfway and the ball ends up say 20 metres up field in the possession of a teammate of the fouled player, who has a promising attacking opportunity, they can't simply leave the ball and expect to get the free kick - the anticipated advantage has already ensued.
If however, the ball ends up with a player who might be able to do something with it, but at no point do they end up with a better opportunity than the free kick would have provided (i.e. a benefit), if they choose not to play the ball, they're effectively forcing your hand into giving the free kick (which you should go with and simply award).
It can be very difficult in these situations to avoid double-dipping - where a team ends up in a better position than the free kick, makes a mistake, then attempt to con the referee into giving the original free kick. This should be avoided where possible by not looking for advantages that are never going to occur, or by failing to signal early enough when the advantage actually ensues.