Related for Berakhot 9:3
בָּנָה בַיִת חָדָשׁ, וְקָנָה כֵלִים חֲדָשִׁים, אוֹמֵר בָּרוּךְ שֶׁהֶחֱיָנוּ. מְבָרֵךְ עַל הָרָעָה מֵעֵין הַטּוֹבָה, וְעַל הַטּוֹבָה מֵעֵין הָרָעָה. הַצּוֹעֵק לְשֶׁעָבַר, הֲרֵי זוֹ תְּפִלַּת שָׁוְא. כֵּיצַד. הָיְתָה אִשְׁתּוֹ מְעֻבֶּרֶת, וְאָמַר, יְהִי רָצוֹן שֶׁתֵּלֵד אִשְׁתִּי זָכָר, הֲרֵי זוֹ תְּפִלַּת שָׁוְא. הָיָה בָא בַדֶּרֶךְ וְשָׁמַע קוֹל צְוָחָה בָּעִיר, וְאָמַר יְהִי רָצוֹן שֶׁלֹּא יִהְיוּ אֵלּוּ בְּנֵי בֵיתִי, הֲרֵי זוֹ תְּפִלַּת שָׁוְא:
If he built a new house or bought new vessels, he says "shehecheyanu" ("who kept us in life, etc.") [Whether or not he has other vessels of the same kind, he says "shehecheyanu."] One blesses over an evil in which good inheres [The gemara explains: as when one's fields are flooded and he loses this year's crop. Though the soil is saturated and the field made more fertile for the years to come, now, however, it is evil, and he blesses "dayan ha'emeth"], and over a good in which an evil inheres [as when one finds a lost object. Even though it is evil for him, for if the king hears of it, he will be beaten and tortured and the object taken from him, now, however, it is good, and he blesses "hatov vehametiv"]. Crying out over what is past constitutes a vain prayer. [If one prays for what has already taken place, this is a vain prayer, for "what has been has been"], as in one's praying: "May it be Your will that my wife bear a son," when she is already pregnant; or, as in one's returning from a journey and hearing wailing within the city, praying: "May it be Your will that it not be coming from my house."