Hi how can I make the "FILTER" function to work if I have multiple parameters separates by comma.

FACTION HERO A X B Y A,B Z

Now if I do a FILTER(B:B; A:A="A") the output will only be X. But Since Z is also in Faction A the output should be X and Z. How can I take care of this?