Is it possible to transfer from Sun/Moon to X/Y?
Unfortunately that is not possible.
You can transfer Pokémon from X/Y/OR/AS to Pokémon Sun/Moon through the Pokébank and you can put Pokémon from Sun/Moon on the Pokébank.
Unfortunately, any Pokémon that has been in a Sun or Moon game cannot be transferred to a 6th generation game (Omega Ruby, Alpha Sapphire, X or Y) even if it is the game it originally came from
It's unfortunate but avoids a lot of potential compatibility problems.
This answer to a similar question has the official picture detailing Pokébank capabilities for all the versions starting with the DS games. You should have a look if ever you wish to buy an older game.