Contact

TEXTBEFORE Function (Gnumeric)

Text Intermediate Gnumeric

TEXTBEFORE in Gnumeric: delimiter extraction, occurrence and case options, with the 1.12.62 numeric-fallback limitation explained.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Availability and version history

  • Introduced: 1.12.61, according to the official release history.
  • Availability: Supported in Gnumeric 1.12.62, based on the function-specific registration.
  • Scope: Desktop; the fn-string function module must be included and enabled.
  • Checked: October 19, 2026. Pinned 1.12.62 registration, argument dispatcher and evaluator reviewed; no native execution.

Quick answer

TEXTBEFORE extracts everything before a specified delimiter occurrence. It is useful for removing a file extension, taking a username before @, or retaining the beginning of a structured product code.

=TEXTBEFORE("Red-Fish-Blue-Fish","-",2)

Expected result: Red-Fish: the second hyphen appears after the second word. With the occurrence argument omitted, the expected output is Red. Gnumeric’s source explicitly defines those meanings. Gnumeric source.

Syntax checked against Gnumeric 1.12.62

=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
Argument Required? Meaning Default
text Yes Text string/cell from which to extract. None
delimiter Yes Literal delimiter string, or array of delimiter strings. None
instance_num No Nonzero number identifying a delimiter occurrence; negatives count backward. 1
match_mode No 0 case-sensitive; 1 case-insensitive. 0
match_end No 0 normally; 1 allows the end of the text to act as a boundary. 0
if_not_found No Numeric fallback for unmatched delimiters/occurrences in the inspected 1.12.62 registration. #N/A

Use commas as shown for the English formula examples. If your locale displays a different list separator, confirm it in Gnumeric’s function assistant. instance_num=0 yields #VALUE! in the tagged implementation. The delimiter is literal text rather than a pattern. Source signature: SA|ffff. Source.

Step-by-step: usernames in an import sheet

  1. Enter the sample addresses in A2:A4 and headings Email (A1) and Username (B1).
  2. Enter =TEXTBEFORE(A2,"@",1,0,0,-1) in B2.
  3. Copy through B4.
  4. Compare with these expected results:
A: Email text Formula (relative to row) Expected B result
alex@example.ca =TEXTBEFORE(A2,"@",1,0,0,-1) alex
pat@shop.net =TEXTBEFORE(A3,"@",1,0,0,-1) pat
incomplete-address =TEXTBEFORE(A4,"@",1,0,0,-1) numeric -1

The successful result represents the substring before the first @; numeric -1 marks an unmatched row in this example. The output column therefore mixes text with a numeric sentinel. It does not confirm the address is valid. Without the final fallback argument, the third row would be expected to return #N/A.

Important 1.12.62 fallback limitation

The sixth argument is not unrestricted text in the inspected release. Both functions are registered with the signature SA|ffff: the four optional arguments, including if_not_found, pass through the numeric argument dispatcher. That dispatcher evaluates each supplied argument before calling the extraction function. For a string in a numeric position, it attempts numeric conversion; a nonnumeric label such as "INVALID" produces #VALUE! before delimiter matching begins.

Consequently, a text fallback can break a call even when the delimiter is present. These are source-reasoned expectations for 1.12.62, not native application observations:

Formula Expected value and type Reason
=TEXTBEFORE("alex@example.ca","@") text alex Omitted fallback does not trigger coercion.
=TEXTBEFORE("alex@example.ca","@",1,0,0,-1) text alex Numeric fallback is accepted; a match exists.
=TEXTBEFORE("incomplete-address","@",1,0,0,-1) number -1 No match; return the numeric sentinel.
=TEXTBEFORE("alex@example.ca","@",1,0,0,"INVALID") error #VALUE! Nonnumeric sixth argument fails before matching.
=TEXTBEFORE("incomplete-address","@",1,0,0,"INVALID") error #VALUE! The same coercion failure occurs with no delimiter.

The extraction callback itself returns the fallback value it receives, but that callback does not bypass the registration’s earlier type check. Reading only the callback would miss this restriction. Use an actual numeric sentinel or omit the sixth argument; do not promise an arbitrary message from this argument. Numeric-looking text may undergo conversion, so it should not be used when preserving a text type matters. This finding is scoped to the pinned 1.12.62 source, not every past or future release.

Argument dispatcher, Gnumeric 1.12.62 and function registration/evaluators establish the order of operations.

Advanced scenario: select a later or final delimiter

Input: Red-Fish-Blue-Fish.

Formula Expected result Why
=TEXTBEFORE("Red-Fish-Blue-Fish","-") Red First occurrence (instance_num=1).
=TEXTBEFORE("Red-Fish-Blue-Fish","-",2) Red-Fish Second occurrence.
=TEXTBEFORE("Red-Fish-Blue-Fish","-",-1) Red-Fish-Blue Last occurrence, counting backward.
=TEXTBEFORE("Region-EAST/ON","east",1,1) Region- Case-insensitive matching.

For filenames, =TEXTBEFORE("report.final.csv",".",-1) is expected to return report.final, cutting off only the final extension. This is different from the default first-period behaviour.

Errors, limitations and troubleshooting

  • #N/A: The requested delimiter occurrence does not exist. Compare uppercase/lowercase, leading spaces and whether the search string is exactly what you intended; use a numeric if_not_found sentinel for the inspected 1.12.62 contract.
  • #VALUE!: Zero is not a valid instance_num. A nonnumeric sixth argument also fails the 1.12.62 numeric dispatcher, even when extraction would otherwise succeed.
  • Wrong portion returned: Check whether you wanted the first (1), second (2) or last (-1) delimiter.
  • Case behaviour: By default searches are case-sensitive; use match_mode=1 only when appropriate.
  • match_end=1: In the tagged source, a positive out-of-range occurrence returns the whole original string, while a negative out-of-range occurrence returns an empty string. Do not silently assume other software handles these cases identically.
  • Delimiter arrays: The source supports them, but this guide does not claim tests of overlapping or multi-character arrays. TEXTBEFORE does not itself enforce a filename or email-validation grammar.
  • Availability: Gnumeric 1.12.61 explicitly introduced this function. The Gnumeric 1.12.62 release tag confirms it still exists; installed plugin configuration may matter.

Excel for Microsoft 365/Excel 2024 also document TEXTBEFORE with similar parameter positions, but do not assume perfect interoperability without testing. Other spreadsheet programs may require combinations of search and extraction functions. Microsoft comparison.

Official reference and verification

Verification status: Checked against the pinned Gnumeric 1.12.62 registration, argument coercion and evaluator source. Example results are source-reasoned and have not been tested in Gnumeric. Gnumeric 1.12.57 predates this function.

  • No genuine Gnumeric screenshots are included; this guide does not use mock application images.