To fix your problem with the formula being deleted, you should actually make it part of your headings, or in my case I usually have 2 header rows. One with the heading and one with the formula. I have my formulas structured so nothing actually shows in the second row and Glide ignores it.
Here is some more info on structureing the header with the formula.