Sayyidina Umar reported that Allah’s Messenger (SAW) said, “If anyone says on seeing someone in afliction:
Praise belongs to Allah Who saved me from that with which He has afflicted you, and caused me to excel over most of those whom He created with a distinct excellence, then he will be saved from the affliction whatever it be as long as he lives.
[Ibn e Majah 3892]