Table of Contents
Introduction to Conditional Text Concatenation in Excel
Microsoft Excel provides powerful tools for manipulating text data, and among the most useful is the TEXTJOIN function. This function streamlines the process of combining multiple text strings from a range, separating them with a specified delimiter. While standard usage of TEXTJOIN is straightforward—simply merging an entire range—many real-world data analysis tasks require conditional aggregation. This means we only want to combine data that meets specific criteria, such as merging names only for employees in a certain department or aggregating products based on their category. This need gives rise to the powerful combination known as TEXTJOIN IF, a mechanism for selective text concatenation based on logical tests.
Prior to the introduction of the TEXTJOIN function (available in Excel 2019 and Microsoft 365), conditional concatenation was a cumbersome process, often requiring complex helper columns, array formulas, or custom VBA scripts. The integration of TEXTJOIN with the IF function revolutionized this task, making it accessible and efficient. Understanding how these two functions interact within a single formula is crucial for anyone working with large, dynamic datasets where specific data subsets need to be summarized into single, readable cells. This method avoids the pitfalls of concatenating empty cells and provides a clean output based purely on the criteria defined by the logical test.
The core principle involves using the IF function to filter the input range dynamically, returning only the values that satisfy the condition, while replacing undesired values with blank strings (""). The TEXTJOIN function then takes this filtered list (or array) and seamlessly merges the remaining elements. The beauty of this approach is its brevity and effectiveness, condensing what might have been a multi-step process into a single, elegant formula. This technique is indispensable for generating custom summaries, reports, or lists directly within a spreadsheet environment without resorting to more complex data manipulation tools.
Understanding the TEXTJOIN Function Syntax
To master the conditional application, we must first establish a firm grasp of the fundamental syntax of the TEXTJOIN function itself. The function requires three mandatory arguments and processes data according to its core structure: TEXTJOIN(delimiter, ignore_empty, text1, [text2], ...). The first argument, delimiter, is perhaps the most critical for readability; it specifies the character or string used to separate the concatenated items. This could be a comma and space (", "), a hyphen ("-"), a pipe symbol ("|"), or any other chosen string. This value must be enclosed in quotation marks.
The second argument, ignore_empty, is a crucial Boolean value that dictates how the function handles cells that are empty or return an empty string (""). If set to TRUE (which is highly recommended for conditional aggregation), TEXTJOIN ignores empty cells, ensuring the output is clean and free of unnecessary delimiters. If set to FALSE, every empty cell in the range is treated as a valid element, resulting in extra delimiters appearing in the final output string, which usually leads to formatting errors or confusion. For conditional merging using IF, setting this argument to TRUE is the standard practice, as the IF function will intentionally generate empty strings for values that fail the criterion.
The remaining arguments, text1, [text2], ..., represent the text items or ranges to be joined. Unlike the older CONCATENATE function, TEXTJOIN efficiently handles entire cell ranges or even multiple ranges, significantly simplifying formula construction when dealing with large datasets. In the context of the TEXTJOIN IF construction, this argument is replaced entirely by the output array generated by the nested IF statement, which acts as the dynamic, filtered list of text items waiting to be combined.
Integrating IF for Conditional Filtering
The power of conditional concatenation lies in the nested IF function. In standard usage, IF performs a logical test and returns one value if the test is true, and another if the test is false. When used within a function that expects an array (like TEXTJOIN or SUMPRODUCT), the IF function is capable of evaluating an entire range of cells simultaneously, generating an output array of corresponding results. This functionality is key to filtering the source data based on a defined criterion before it reaches the aggregation stage.
The syntax for the nested IF statement typically looks like this: IF(test_range=criterion, value_if_true_range, value_if_false). Here, the test_range is the column containing the criteria we wish to evaluate (e.g., the ‘Conference’ column), and criterion is the specific condition (e.g., “Western”). If the condition is met, the formula returns the corresponding value from the value_if_true_range (e.g., the ‘Team Name’ column). Crucially, if the condition is not met, the formula must return an empty string ("") as the value_if_false. This explicit use of the empty string is what allows the parent TEXTJOIN function, when set to ignore_empty=TRUE, to effectively discard the unwanted results.
It is important to note the difference between returning an empty string ("") and returning the Boolean value FALSE. While some older array formula constructions might interpret FALSE as zero or skip it, using "" guarantees that the value is treated as an empty text element, which is precisely what the TEXTJOIN function is designed to ignore when its second argument is set to TRUE. This precise interaction ensures maximum compatibility and error prevention when dealing with concatenated text strings.
The Complete TEXTJOIN IF Formula Syntax
The composite formula structure for conditional text aggregation is highly efficient and follows this definitive pattern: =TEXTJOIN(delimiter, TRUE, IF(criteria_range=condition, values_to_join_range, "")). This combines the selective power of IF with the aggregation efficiency of TEXTJOIN. For instance, if you aim to combine text values in Column A only when the corresponding cell in Column B contains the text “Western,” the implementation is direct.
The formula below illustrates the precise structure required to achieve this conditional merger, using a comma and space (", ") as the separation mechanism. This formula is designed to look through a specified range, identify matches, and return a concatenated list of only the successful matches.
=TEXTJOIN(", ",TRUE,IF(B2:B11="Western",A2:A11,""))
In this specific example, the formula executes the following logic: For every cell from B2 through B11, check if the value equals “Western.” If it does, return the corresponding text from the A2:A11 range into the virtual array; otherwise, return an empty string (""). The TEXTJOIN function then processes this resulting array, ignoring all the empty strings generated by the failed criteria and cleanly merging only the remaining team names using ", " as the separator. This simple line of code accomplishes a sophisticated filtering and aggregation task seamlessly.
Practical Application: Filtering Data by Criteria
To solidify the understanding of TEXTJOIN IF, consider a common scenario involving a dataset of professional sports teams. Suppose we are tracking various teams, and the data includes both the team name and the conference they belong to (e.g., Eastern or Western). Our objective is to generate a concise, comma-separated list of all teams belonging exclusively to the Western conference, isolating them from the rest of the dataset. This is a perfect use case for conditional text joining.
We are working with the following example dataset in Excel, organized into two primary columns: Team Name (Column A) and Conference (Column B). Our goal is to extract the names from Column A only when the condition in Column B is met. This demonstration highlights how efficiently the formula handles mixed data, selectively pulling only the required information without manual sorting or filtering.
The visual representation of our starting data is provided below. Notice the alternating conferences throughout the range B2:B11. We aim for a single output cell that aggregates the corresponding values from the adjacent cells in Column A based on the “Western” conference designation.

Step-by-Step Implementation Guide
Implementing the TEXTJOIN IF formula requires precise execution, especially regarding range definitions and argument placement. We will place our resultant formula in cell D2, which will serve as our summary cell for the Western Conference teams. This separation ensures the output does not interfere with the source data.
Define the Delimiter: Start the formula with
=TEXTJOIN(", ". We choose the comma followed by a space (", ") as our preferred delimiter to ensure high readability between the team names.Specify Ignore Empty: Set the next argument to TRUE:
=TEXTJOIN(", ",TRUE,. This instructs the function to skip all intermediate empty values generated by the filtering step, which is crucial for a clean output.Nest the IF Condition: Introduce the IF function. Define the criteria range (Column B) and the condition:
IF(B2:B11="Western",. This checks every cell in the conference column for a match against the literal string “Western.” Remember that Excel text comparisons are generally case-insensitive unless specified otherwise.Specify Values to Return: If the condition is met, instruct IF to return the corresponding value from the team name column:
A2:A11,. These are the values we ultimately want to join.Handle False Outcomes: If the condition is not met (i.e., the team belongs to the Eastern conference), return an empty string:
"". The complete nested IF statement is nowIF(B2:B11="Western",A2:A11,"").Complete and Execute: Close both the IF and TEXTJOIN functions. The full formula entered into cell D2 is:
=TEXTJOIN(", ",TRUE,IF(B2:B11="Western",A2:A11,""))In modern versions of Excel (supporting dynamic arrays), simply pressing Enter is sufficient. For older versions or specific configurations, this formula might need to be entered as a legacy array formula by pressing Ctrl+Shift+Enter, wrapping the formula in curly braces {}.
Analyzing the Formula Output and Verification
Upon successful entry of the formula into cell D2, Excel processes the instruction by first generating an intermediate virtual array. This array contains the names of the Western teams mixed with empty strings where Eastern teams were filtered out. The TEXTJOIN function then processes this array, aggregates the valid text entries, and presents the final, clean output in the target cell.
The resulting cell D2 displays the combined list of team names. This outcome confirms that the logical criteria successfully filtered the dataset, and the aggregation function correctly combined only the designated teams, separated neatly by the chosen delimiter.
The following screenshot illustrates the result after the formula is applied to cell D2, demonstrating the immediate and accurate conditional aggregation:

Cell D2 has joined together each of the team names that belong to the Western conference, with a comma used as a delimiter. To ensure accuracy, we can manually cross-reference the output list against the original dataset. Every team listed in D2 must correspond to an entry in the Conference column (B2:B11) marked as “Western.”

If we view the original dataset, we can confirm that each of the teams included in cell D2 do indeed belong to the Western conference, confirming the precision and effectiveness of the TEXTJOIN IF structure. This method provides robust conditional data extraction in a format that is ready for reporting or further analysis.
Customizing Delimiters and Error Handling
One of the most user-friendly features of the TEXTJOIN function is the ease with which the delimiter can be customized. While we used ", " in the primary example, you are free to use any text string, symbol, or combination thereof. For example, if you wished to separate the team names using a pipe symbol (|) or a combination like " -- ", you would simply modify the first argument of the function accordingly. The flexibility of the delimiter allows the aggregated output to conform to various reporting or coding standards required by external systems or visualization tools.
Note #1: To use a different delimiter to join together the text values, simply specify that delimiter in the first argument of the TEXTJOIN function. For instance, replacing ", " with " | " would change the output from Team A, Team B to Team A | Team B.
Furthermore, it is essential to consider scenarios where the specified criterion might not be found in the dataset. If, for instance, we searched for a conference called “Central” which did not exist in the B2:B11 range, the IF function would return an array consisting entirely of empty strings (""). Because the second argument of TEXTJOIN is set to TRUE, the function ignores all these empty strings and the final output cell would simply remain blank (or return ""), rather than throwing an error or displaying extraneous delimiters. This robust default behavior contributes significantly to the reliability of TEXTJOIN IF for dynamic reporting where criteria matches are not guaranteed.
Advanced Considerations: Array Formulas and Compatibility
While modern versions of Excel (Microsoft 365, Excel 2021) handle the TEXTJOIN IF structure natively as part of the Dynamic Arrays capability, understanding the concept of an array formula remains important, especially for users on older software versions. In legacy Excel environments, formulas that perform operations across a range and return a range of results (like the nested IF here) must be explicitly designated as an array formula. This required the user to press Ctrl+Shift+Enter (CSE) instead of just Enter.
When executed correctly as a CSE formula, Excel would automatically wrap the formula in curly brackets (e.g., {=TEXTJOIN(...)}). If the curly brackets are missing in older versions, the formula typically fails, often returning a #VALUE! error or simply concatenating the first item in the range incorrectly. Users relying on cross-platform compatibility should test the formula to see if the CSE input method is required. The move toward dynamic arrays has largely eliminated this complexity, making TEXTJOIN IF more user-friendly across the board.
Another technical consideration is handling numerical data within the IF function. If the values to be joined (A2:A11 in our example) were numbers instead of text, the IF statement would return those numbers. Although Excel often coerces numbers into text strings automatically within this context, for maximum reliability, especially in complex scenarios, one might consider wrapping the return range in the TEXT function (e.g., TEXT(A2:A11, "General")) to ensure all inputs are treated as text before concatenation. This guarantees a smooth conditional aggregation regardless of the source data type.
Cite this article
stats writer (2025). Excel: Use TEXTJOIN IF Formula. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/excel-use-textjoin-if-formula/
stats writer. "Excel: Use TEXTJOIN IF Formula." PSYCHOLOGICAL SCALES, 17 Nov. 2025, https://scales.arabpsychology.com/stats/excel-use-textjoin-if-formula/.
stats writer. "Excel: Use TEXTJOIN IF Formula." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/excel-use-textjoin-if-formula/.
stats writer (2025) 'Excel: Use TEXTJOIN IF Formula', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/excel-use-textjoin-if-formula/.
[1] stats writer, "Excel: Use TEXTJOIN IF Formula," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, November, 2025.
stats writer. Excel: Use TEXTJOIN IF Formula. PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.
