סימן קצט סעיף ח
לְאַחַר שֶׁהִנִּיחוּ אֶת הַמֵּת בַּקֶּבֶר, מְהַפְּכִין אֶת הַמִּטָּה שָׁלֹשׁ פְּעָמִים, כִּי מִטָּה בְּגִימַטְרִיָא דִין, לְרַמֵּז שֶׁיִתְהַפֵּךְ הַדִין לְרַחֲמִים וְהַהֶסְפֵּד לְמָחוֹל. זֵכֶר לַדָּבָר, הָפַכְתָּ מִסְפְּדִי לְמָחוֹל לִי. וּבְיוֹם שֶׁאֵין אוֹמְרִים תַּחֲנוּן, אֵין עוֹשִׂין זֹאת.
After the body is laid in the grave, the bier is turned over three times, for the numerical value of the word mittah (bed, bier) is the same as that of the word Din (judgement). This is an omen that the judgement will be turned into mercy, and the mourning into joy. The verse alludes to this, "You turned my mourning into dancing."5Psalms 30:12. On a day when Tachanun is not said, this is not done.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)