DETECTLANGUAGE function

DETECTLANGUAGE returns the ISO 639-1 language code of input text, enabling language-based filtering and analysis of multilingual support tickets.

=DETECTLANGUAGE(text_or_range)

Generate a DETECTLANGUAGE formula

Describe what you need. The generator will reach for DETECTLANGUAGE where DETECTLANGUAGE is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How DETECTLANGUAGE reads its arguments
text_or_rangerequiredDETECTLANGUAGE
ArgumentRequiredDescription
text_or_rangeRequiredText or a single cell/range containing text to analyze. Returns #N/A if the cell is empty, contains only non-language content, or language patterns are too sparse to identify.

Returns

A text string representing the two-letter ISO 639-1 language code (e.g., 'en', 'es', 'fr', 'zh').

Availability

Excel: Not available · Google Sheets: Supported

Worked examples

1. Detect the language of a single support ticket note

Ticket IDNote
T-1001Please fix my account access immediately
=DETECTLANGUAGE(G2)

Result: en

DETECTLANGUAGE analyzes the English phrase and returns 'en', the standard ISO 639-1 code. Single-cell detection is the simplest use case, returning one language code per formula.

2. Detect languages across all ticket notes at once

Note
Please fix my account access immediately
¡Necesito ayuda con mi contraseña!
Merci pour votre aide rapide
我的订单有问题
Bedankt voor de ondersteuning
=ARRAYFORMULA(IF(G2:G6="","",DETECTLANGUAGE(G2:G6)))

Result: enesfrzhnl

ARRAYFORMULA applies DETECTLANGUAGE to each row without copying the formula down manually. The IF statement skips empty cells, returning an array of five language codes in parallel.

3. Flag non-English tickets for translation routing

Ticket IDNoteAction
T-1001Please fix my account immediately
T-1002¡Necesito ayuda con mi contraseña!needs_translation
T-1003Merci pour votre aideneeds_translation
T-1004我的订单有问题needs_translation
T-1005Bedankt voor ondersteuningneeds_translation
=ARRAYFORMULA(IF(DETECTLANGUAGE(G2:G6)="en","","needs_translation"))

Result: needs_translationneeds_translationneeds_translationneeds_translation

Combining IF with DETECTLANGUAGE creates a helper column for workflow automation. Only the English ticket (T-1001) returns blank; non-English tickets are marked for routing to translation-capable agents.

Common errors

Which DETECTLANGUAGE error are you seeing?
DETECTLANGUAGE returned an error#N/A
Verify the cell contains meaningful text with at least a few words. Use IFERROR(DETECTLANGUAGE(text),'unknown') to provide a fallback for empty or ambiguous entries.
#VALUE!
Ensure input contains actual words or letters. For mixed content like 'Ticket#12345 ¡Hola!', pre-filter with REGEXREPLACE to extract language text before passing to DETECTLANGUAGE.
#REF!
Check that all referenced cells and ranges still exist. Re-enter the formula pointing to valid cells, or use INDIRECT() to make references more robust if columns are frequently reordered.
ErrorWhy it happensHow to fix it
#N/AThe cell is empty, contains only whitespace, or the text lacks sufficient language-specific word patterns for reliable detection.Verify the cell contains meaningful text with at least a few words. Use IFERROR(DETECTLANGUAGE(text),'unknown') to provide a fallback for empty or ambiguous entries.
#VALUE!The input contains only numbers, emojis, special characters, or symbols—text without actual language content that can be analyzed for linguistic patterns.Ensure input contains actual words or letters. For mixed content like 'Ticket#12345 ¡Hola!', pre-filter with REGEXREPLACE to extract language text before passing to DETECTLANGUAGE.
#REF!The formula references a cell or column that has been deleted, moved, or is otherwise invalid in the current sheet structure.Check that all referenced cells and ranges still exist. Re-enter the formula pointing to valid cells, or use INDIRECT() to make references more robust if columns are frequently reordered.

Tips and when to use something else

  • Use ARRAYFORMULA to apply DETECTLANGUAGE across entire columns at once, eliminating the need to copy the formula down thousands of rows.
  • Combine DETECTLANGUAGE with GOOGLETRANSLATE in one formula: =GOOGLETRANSLATE(text, DETECTLANGUAGE(text), 'en') to auto-detect and translate tickets in parallel.
  • Always wrap DETECTLANGUAGE in IFERROR or IFNA for production workflows: =IFERROR(DETECTLANGUAGE(text),'mixed') handles edge cases like blank cells or unrecognizable text gracefully.
  • For language-based filtering without helper columns, use SUMPRODUCT with ARRAYFORMULA to count or sum: =SUMPRODUCT((ARRAYFORMULA(DETECTLANGUAGE(range))='language_code')*1).

Frequently asked questions

What language codes does DETECTLANGUAGE support?
DETECTLANGUAGE returns standard ISO 639-1 two-letter codes: 'en' (English), 'es' (Spanish), 'fr' (French), 'de' (German), 'zh' (Chinese), 'nl' (Dutch), 'ja' (Japanese), 'pt' (Portuguese), and 50+ others. See Google's official language list for the complete supported set.
Can DETECTLANGUAGE automatically translate my tickets to English?
Yes, combine it with GOOGLETRANSLATE: =GOOGLETRANSLATE(note, DETECTLANGUAGE(note), 'en'). This detects the original language and translates to English in a single formula, ideal for building multilingual support workflows.
Why does DETECTLANGUAGE return #N/A on single words or short phrases?
DETECTLANGUAGE needs sufficient linguistic context—typically at least 2–3 words—to confidently identify a language. Single words like 'Hello' or numeric identifiers lack enough pattern data. Use IFERROR() to handle these gracefully or ensure text inputs are longer phrases.
How do I route tickets by detected language using QUERY?
First, create a helper column with =ARRAYFORMULA(DETECTLANGUAGE(notes_range)). Then filter: =QUERY({ticket_data}, 'where Language="es" order by CSAT'). This routes Spanish-language tickets separately for language-matched agent assignment.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17