How to Use Excel IF Formula with Text Containing Square Brackets
Question details
The user needs to construct an Excel IF formula that correctly evaluates text containing square brackets, quotation marks, and commas, typically generated by external tools like Power Automate.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Comparing imported or pasted string data containing brackets and quotes from external sources to verify if it matches an expected text pattern.
- Observed behavior
- The formula may fail or return incorrect results if the exact spacing, punctuation, and specific quotation mark types (smart vs. straight) do not exactly match the source text.
Verify the exact format of your imported text, taking special note of any hidden spaces or curly 'smart' quotation marks that might differ from standard straight quotes.
Use Exact String Matching in the IF Formula
Embed the exact target string directly inside the IF function, ensuring all brackets and punctuation match perfectly.
Square brackets are treated as standard text characters in Excel when enclosed in double quotes. The most common cause of failure is mismatched quotation mark styles or invisible spacing.
Click on the cell where you want the IF formula result to be displayed.
Type the IF function, wrapping your entire target string in straight double quotes. For example: =IF(A1="[“water”,”stone”,”plants”]", 1, 0)
Ensure that the inner quotation marks (such as “ ”) in your formula exactly match the type of quotes generated by Power Automate.
Press Enter to calculate the result. If the text is an exact match, the formula will output your specified true value.

Reference a Helper Cell for Complex Text Comparisons
Store the complex string in a separate cell and reference it in your IF formula to avoid syntax errors with nested quotes.
Handle Complex Formulas Easily with WPS Spreadsheet
WPS Spreadsheet is a robust, free alternative for managing data, handling complex text strings, and executing logical formulas like IF. It seamlessly processes imported data from tools like Power Automate and offers a highly compatible environment for your daily data analysis.
- 1. Open your spreadsheet: Launch WPS Spreadsheet and open the document containing your imported Power Automate data.
- 2. Enter the IF formula: Select an empty cell and input your IF formula to compare your data against the expected text string with brackets.
- 3. Evaluate and apply: Press Enter to see the result, and drag the fill handle to apply the logic down your entire data column.

Frequently Asked Questions
Why does my IF formula return false even when the text looks identical?
This usually happens due to hidden trailing spaces, leading spaces, or differing quotation mark types (straight vs. curly). You can use the TRIM function to remove extra spaces or copy the exact text from the source to ensure a perfect match.
Do I need to escape square brackets in Excel formulas?
No, square brackets inside a text string (when enclosed in outer double quotes) are treated as regular text characters. They do not need to be escaped in an IF function's text comparison.
How do I handle quotation marks within a string in an IF formula?
If the text contains standard straight quotes, you must double them up to escape them (e.g., """water"""). If the string uses smart quotes (“”), you can include them normally as long as the entire string is wrapped in standard straight quotes.




