Conditional trigger another pipeline

Hello
In my CI, I have 3 stages. In the first one, I check if an another library is build at the correct version. If not I set a variable with a TAG. In the second stage, I check (with Only, if the variable is set to a TAG) and trigger the build of the library (by using the Trigger command).
If I understand well the Except/only command are executed at the begginning of the pipeline and so the trigger is never executed.
How can I have a conditionnel trigger
Thanks for you answer
Laurent