الْحَمْدُ لِلَّهِ الَّذِي عَافَانِي مِمَّا ابْتَلَاكَ بِهِ وَفَضَّلَنِي عَلَى كَثِيرٍ مِمَّنْ خَلَقَ تَفْضِيلًا
Transliteration
Alhamdu lillahilladhi 'afani mimmabtalaka bihi wa faddalani 'ala kathirin mimman khalaqa tafdila
English meaning
All praise is for Allah who saved me from that which He tested you with and who greatly favoured me above much of His creation.
When is it recited?
Said silently (not to the afflicted person) upon seeing someone in hardship.
Its virtue
Whoever says this will be protected from that affliction.
Source
Tirmidhi, Da'awat 76, 3431