I think if an agent likes Y they should like X too. You should ask this agent, what do you see in Y that you don't in X? Cause if it's the writing, I would rethink it. You want the agent to like all your writing to represent every piece of your work. If this agent is that picky, then you might have a problem in the future and can't get out cause you have a contract with them.
I could definitely see why an agent would turn down something, particularly if this is a case of nonfiction. I kind of assumed it was from the explanation, however it may not be. But let's say someone has written a book that shows good knowledge, good writing, etc., but is on a topic that's just so completely saturated at the moment that this piece provides nothing new (fiction or non-fiction) and wouldn't sell. However, the author also happens to be a specialist in another field that isn't saturated and would be pretty original (or for fiction, the author, aside from writing YA paranormal vampire romances, also has been writing a series about something less common like leprechauns). I could see how an agent could believe that the second category would be a stronger work with a higher likelihood of making a sale.
That being said, I don't know how common this is, or what would be the best choice for the author. Obviously it's a personal choice.
I don't know if this has any bearing on the situation, but I spoke to an editor once about six or seven years ago who had asked me if I would write a novel with an Amish setting (I have family who are Amish). I had said I was interested, and he had said he would get back to me. He never did, and this is back in the days before I knew about nudging and what not so I figured he wasn't really that interested after all, but I've thought about that before, and on one hand Amish novels, particularly Amish romance are actually selling pretty well right now. Had I taken him up on this, I might have been able to catch the trend that grew out of it and might have seen some earlier success. On the other hand, it's not really my style, so to speak. I like horror and suspense, and those are the kind of stories I want to tell. An Amish settlement having to deal with some demon monster? That's my kind of cool.
Point being, I'm glad I didn't follow up. While I might have been able to sell a few books, I wouldn't have been writing what I want to be writing . Instead I have spent the past few years improving my skills and now I'm at a point where I might be able to find success writing what I enjoy.
So if Y is something you're interested in and something that you
want to write, my advice would be to go for it and give it a try. Even if that agent didn't want it, someone else might. But if it would mean setting aside what you want to do in order to potentially get an agent, I would suggest really considering your career and what you hope to gain from it. It's a difficult decision.
Good luck.