Suppose I have the event $Y$,
$$ Y = \begin{cases} y_1,& p\\ y_2,& (1-p) \end{cases} $$
and the event $X$ that only occurs when $Y=2$,
$$ \{X|Y=y_2\} = \begin{cases} x_1,& q\\ x_2,& (1-q) \end{cases} $$
Then given $x$ occurs we know that $y=y_2$,
\begin{array}{l|ll} P(y|x) &y_1 &y_2 \\ \hline x_1 &0 &1 \\ x_2 &0 &1 \end{array}
and given $y=y_1$, we know $x$ didn't occur,
\begin{array}{l|ll} P(x|y) &x_1 &x_2 \\ \hline y_1 &0 &0 \\ y_2 &q &(1-q) \end{array}
And the joint pmf can be calculated multiplying $p(y|x)$ with $p(x)$.
Where $p(x) = p(x|y=y_1)p(y_1) + p(x|y=y_2)p(y_2)$. Since $p(x|y=y_1) = 0$, we have,
$$ p(x) =\begin{cases} (1-p)q,& x=x_1\\ (1-p)(1-q),& x=x_2 \end{cases} $$
Something doesn't seem right. If I find the joint pmf, and then try to find the marginal of $Y$ from the the joint, I have that $p(y=y_1) = 0$.
Did I do something wrong here? It seems to be related to the fact that $x$ doesn't occur during the event $y=y_1$. How would I find the joint pmf?
Your calculation for $p(x)$ adds up to $1-p$ when we need it to add up to $1$. The issue is that you are considering only $x_1$ and $x_2$ as possibilities for $X$, but not considering the third valid possibility, which is "$X$ does not occur", which has probability $p$.