For example, if a person tries to put on pasul tefillin (not aware that they are pasul) and is prevented from doing so for reasons beyond his control, he doesn’t receive credit for putting on tefillin. He receives credit only for the deed he tried to do – which, in this case, was putting on pasul tefillin.
Now we can understand why Yirmiyahu asked Hashem to arrange that the recipients of the tzedakah of Anasos’ residents should not be poor people. Giving money to someone who is not a pauper is not a mitzvah. If a person attempts to do that act, he is not trying to perform an act which is actually a mitzvah – and therefore receives no credit for it.