If you're able to determine that significant portions of the question are actually irrelevant to the question that you were asking then you should absolutely remove that content. Doing so makes it much easier for people reading the question to understand it.
Likewise, if you feel that the wording of portions of your question is resulting in people misunderstanding what the question is asking you should absolutely be editing those portions of the question so that they are clearer, and so that readers will be more likely to understand what you're asking.
If, on the other hand, you simply realize now that the quesiton that you asked isn't going to help you solve your problem, and that the quesiton you wished you would have asked is something different, then it's not appropriate to edit the question into one that is asking for something completely different just because you're now more interested in the different question. If this is the case then you simply need to ask a new question (and are free to leave the original question behind if there's a chance others might be interested in that question).