the syntax is a bit off, what you are looking to use is an inline If, using this with this syntax:
/docommand ${If[condition,true,false]}
the solution would be something like this:
/dgre /docommand $\{If[$\{AdvPath.Following},/afollow off,/afollow spawn ${Me.ID}]}
We use the \ in the datavars to make sure they are parsed on the reciever and not the sender.