if certain options in question A are selected
Please, which options, which type of question?
So a rough answer:
1. Create a question of type equation (eq1) that gives a result of 1, if the "certain options" are selected or 2, if not.
No example possible without more details.
2. Create a question of type equation (eq2) where you generate a random number between 1 and 2, if the first equation is 1 and a fixed value of 2, if the first equation is 2.
Like
{if(eq1==1,if(is_empty(eq2),rand(1,2),eq2),2)}
So, only if eq1==1 a random number is created otherwise the value of eq2 is 2.
And your question B gets the relevance equation: eq2==1
Joffm
If I take your topic into account "If question A is answered yes"
then it is more simple; you have only one equation
eq2
{if(QA=="Y",if(is_empty(eq2),rand(1,2),eq2),2)}