Formatting a DAX is good practice as it makes your DAX code well defined and readable.
If you have written a DAX code which is lengthy and complicated, and it is not well formatted then it does get difficult to read and understand.
Therefore, to format your DAX code you can use DAX Formatter tool which is free and created by SQLBI.
It allows you to convert your complicated/messy DAX code into clean and readable format.
As you can see, here we have one DAX code.
To format this code, just copy the code and visit to website : https://www.daxformatter.com/.
And paste your code as shown below.
After pasting a DAX code, click on FORMAT button.
And you can see it converts DAX code into clean and readable format.
Now you can copy the DAX code and paste into your PBI file.