@Melissa,
I had the same problems with the preformatted text, and @Nick_M figured it out. If you put a blank line between the first line ( measure name = ) and the start of your DAX code, the preformatting option will work perfectly.