Formula Patterns

Screen stocks by sector and financial metrics

Use the Stock Screener to filter companies within a specific sector and rank them by financial metrics such as Operating Profit Margin TTM, Return on Equity, or Debt to Equity.

Plan requirement: Sector filtering is a basic filter available on all plans from Investor up. Advanced financial metrics like Operating Profit Margin TTM require the Analyst plan or a commercial plan.

Screen a sector by operating profit margin

Build a screen that returns Technology companies with an Operating Profit Margin TTM above 15%, ordered by margin from highest to lowest.

  1. Open the Stock Screener from the Google Sheets dropdown, below the Function Generator. For the full UI walkthrough, see the Stock Screener guide.

  2. Add a sector filter and set it to Technology.

  3. Add an Operating Profit Margin TTM filter and set the operator to > and the value to 0.15.

  4. In the metrics section, select symbol, sector, operatingProfitMarginTTM, and marketCap so they appear in the output.

  5. Set the order to ob=operatingProfitMarginTTM so the highest margins appear first.

  6. Click Generate to insert the formula into the active cell.

The resulting formula looks like this:

=SF_SCREEN("sector=Technology&operatingProfitMarginTTM>0.15", "symbol&sector&operatingProfitMarginTTM&marketCap", "ob=operatingProfitMarginTTM")

Swap the metric or sector

The same pattern works with any sector and any advanced filter. Replace the sector value with Healthcare, Energy, or another sector, and replace the margin filter with another financial metric.

  • Return on Equity TTM: returnOnEquityTTM>0.20

  • Debt to Equity TTM: debtToEquityRatioTTM<0.50

  • Price to Earnings TTM: priceToEarningsRatioTTM<15

  • Free Cash Flow Yield TTM: freeCashFlowYieldTTM>0.05

Chain multiple conditions with &. For example, screen the Energy sector for companies with an Operating Profit Margin TTM above 10% and a Debt to Equity Ratio TTM below 1:

=SF_SCREEN("sector=Energy&operatingProfitMarginTTM>0.10&debtToEquityRatioTTM<1", "symbol&sector&operatingProfitMarginTTM&debtToEquityRatioTTM&marketCap", "ob=operatingProfitMarginTTM")

Limit and format the output

Use options to keep the result manageable:

  • limit=50 returns only the first 50 rows.

  • NH removes the header rows so you can feed the result directly into a chart or pivot table.

  • ob=-marketCap orders by market cap ascending instead of descending.

Options are chained with &:

=SF_SCREEN("sector=Technology&operatingProfitMarginTTM>0.15", "symbol&sector&operatingProfitMarginTTM&marketCap", "ob=operatingProfitMarginTTM&limit=50&NH")

Looking for a sector average instead?

The Stock Screener returns individual companies, not aggregated sector averages. If you need the average valuation or margin for an entire sector, use Sector PE or Industry PE instead.

For the complete list of available filters, metrics, and options, see the Stock Screener function reference.

Was this helpful?