You can use three different margins to gauge profitability: gross margin, operating margin, and overall profit (net income) margin. All three are computed by dividing profits by total sales:
margin = profit/total sales
Margins can be computed for any period (e.g., days, weeks, months), but for stock analysis, the only periods used are the last quarter (three months), the last four reported quarters (TTM), or a fiscal year. The only difference between the three types of margins is the profit figure that is compared to sales.