CONCAT() – Joins text strings together
The CONCAT() function (short for concatenate) combines two or more text strings, or the content of cells, into a single string.
Syntax
CONCAT(text1, text2, ...)
- text1: The first text item or cell reference to join.
- text2: The second text item or cell reference to join.
- ... (optional): Additional text items or cell references to join. You can include multiple arguments.
Arguments can be literal text strings (enclosed in double quotes), numbers, or references to cells containing any data type (which will be converted to text if not already).
Basic example
CONCAT(T1A1, " ", T1B1)
Combines the content of cell T1A1, a space character, and the content of cell T1B1.
- If T1A1 = "Hello" and T1B1 = "World": CONCAT(T1A1, " ", T1B1) → "Hello World"
- If T1A1 = "Project ID:", T1B1 = 123, and T1C1 = "-Draft": CONCAT(T1A1, T1B1, T1C1) → "Project ID:123-Draft"
- Using literal text and a cell reference, if T1D1 = "User": CONCAT("Name: ", T1D1, ", Status: Active") → "Name: User, Status: Active"
Key features
- String merging: Its primary purpose is to join multiple pieces of text.
- Multiple arguments: Can accept a variable number of arguments to concatenate.
- Type conversion: Numbers or other data types in referenced cells are typically converted to their text representation before concatenation.
- Spacing: CONCAT() does not automatically add spaces between arguments; you must explicitly include spaces as separate arguments (e.g., " ") if needed.
Practical uses
- Creating full names from separate first and last name cells: CONCAT(firstNameCell, " ", lastNameCell).
- Generating report labels or identifiers by combining static text with cell values.
- Assembling addresses from street, city, and postal code cells.
- Constructing custom messages or descriptions based on other cell data.
Common mistakes
- Forgetting spaces: CONCAT(T1A1, T1B1) with "Hello" and "World" yields "HelloWorld". To get "Hello World", use CONCAT(T1A1, " ", T1B1).
- Text not in quotes: Literal text arguments must be enclosed in double quotes. CONCAT(Hello, World) would try to find cells named Hello and World, not use the literal words.
- Using
+for numbers: While+can concatenate strings in MathGrid if text is involved (e.g. "Total: " + T1A1), CONCAT() is specifically for joining multiple items. If you try CONCAT(5 + 10), it might evaluate5+10to15first, then concatenate "15". If you mean to concatenate "5" and "10", use CONCAT("5", "10") or CONCAT(cellWith5, cellWith10). The+operator outside CONCAT behaves differently if all operands are numbers (it sums them).
MathGrid ©
MathGrid ©