How to Use OR Logic in a Power Query Conditional Column in Excel
Question details
The user wants to use OR logic in a Power Query conditional column to check if a text column contains one of multiple specific values and return a designated category.

- Product
- Excel Power Query
- Device & OS
- not provided
- Scenario
- Creating a conditional column that evaluates multiple text criteria to return a specific outcome using an OR condition.
- Observed behavior
- The user needs to output a category string when a column matches either of two text conditions, but the standard graphical interface lacks a direct 'OR' operator for conditional outputs.
Ensure that your Power Query formula bar is visible before proceeding, as you will need to manually edit the M code. You can enable it by checking 'Formula Bar' under the View tab in the Power Query Editor.
Modify Conditional Column via Formula Bar or Advanced Editor
Since the Power Query graphical interface does not natively support an OR operator for a single conditional output, the best method is to create a basic conditional column first and then append the 'or' operator in the M code.
Power Query's M formula language supports complex logical operators, but they must often be typed manually. The easiest workflow is to let the user interface generate the base code, and then manually adjust the logic to suit your needs.
Open the Power Query Editor, navigate to the 'Add Column' tab, and select 'Conditional Column'. Set up your first condition (e.g., If [Reporter Team] contains 'L3 SW' then 'L3 SW') and click OK.
Make sure the Formula Bar is enabled from the View tab, or click 'Advanced Editor' on the Home tab to view the M code generated for your new conditional column step.
Locate the 'if' statement in the code. Append your second condition using the lowercase 'or' operator. For example: `if Text.Contains([Reporter Team], "L3 SW") or Text.Contains([Reporter Team], "CP Integration") then "L3 SW" else "nothing"`.
Press Enter in the Formula bar or click 'Done' in the Advanced Editor to apply the OR logic to your column. Verify that the column now correctly categorizes your data based on either condition.

Need a Lightweight Alternative to Process Your Spreadsheets?
While complex Power Query M scripting is specific to Microsoft Excel, WPS Office provides a highly compatible, fast, and free alternative for your daily data analysis and spreadsheet tasks.
- 1. Download and Install WPS Office: Visit the official WPS website to download the free installation package and follow the on-screen instructions to install it on your device.
- 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing Excel files directly, without worrying about format conversion issues.
- 3. Analyze Your Data: Utilize built-in pivot tables, formulas, and chart tools to process and visualize your data effortlessly.

Frequently Asked Questions
Can I use the graphical interface in Power Query to apply OR logic?
The standard Conditional Column dialog box in Power Query does not natively support combining multiple conditions with an 'OR' operator for a single conditional outcome line. You must use the Formula Bar or Advanced Editor to manually add the 'or' keyword to the M code.
Why is my Power Query 'or' statement throwing a syntax error?
Power Query M formula language is case-sensitive. Make sure you are using the lowercase 'or' rather than uppercase 'OR'. Additionally, check that your function names, such as 'Text.Contains', are correctly capitalized.
Can I chain multiple OR conditions together in Power Query?
Yes, you can chain as many conditions as needed using the 'or' operator. For example, your formula can be structured as: `if Condition1 or Condition2 or Condition3 then Result else Default`.




