SheetSense

Convert SQL to an Excel formula

If you know SQL and have to work in a spreadsheet, the mapping is shorter than it looks. A filtered aggregate becomes SUMIFS or COUNTIFS, a JOIN becomes a lookup, and CASE WHEN becomes IFS or nested IF. GROUP BY has no single formula, so you list the groups and write one SUMIFS per group, or use a pivot table.

SheetSense helps in both directions. The Formula Translator writes the SQL for an Excel formula, and reading a few of those pairs is a quick way to learn the pattern. For your own data, upload the file and ask for the formula in a sentence.

Worked example: filtered SUM to SUMIFS

Table orders has region, order_date and revenue. In Excel the same data sits in columns B, C and D.

SQL
SELECT SUM(revenue)
FROM orders
WHERE region = 'West'
  AND order_date >= DATE '2026-01-01';
Excel
=SUMIFS(D2:D5000,B2:B5000,"West",C2:C5000,">="&DATE(2026,1,1))

Each AND condition in the WHERE clause becomes one range and criterion pair. SUMIFS returns 0 when no row matches, while SQL SUM returns NULL. Excel also ignores capitalization in text comparisons, while some databases do not.

How it works

  1. 01Identify what the query returns: one number, a list of rows, or a value per group.
  2. 02For one number, use SUMIFS, COUNTIFS or AVERAGEIFS with one pair per WHERE condition.
  3. 03For a JOIN, use XLOOKUP or INDEX and MATCH on the key column.
  4. 04For a value per group, build a pivot table or write one SUMIFS per group.

Common questions

What replaces SELECT DISTINCT?
In Excel 365 and Google Sheets, UNIQUE returns the distinct values of a column or the distinct rows of a range.
What replaces CASE WHEN?
IFS for several conditions, or a single IF for two outcomes. SWITCH works when you are matching exact values.
Can I paste a whole SQL query and get a formula?
The translator is built for formulas. For a query, ask in a sentence in the workspace on your own data, or rebuild it piece by piece with the patterns above.

Try it on your own formula

The Formula Translator is free for 5 formulas a day, with no account.