Power Query Problems

How to Use OR Logic in a Power Query Conditional Column in Excel

Huma Ashraf ChHuma Ashraf Ch Nov 10, 2026 868 views

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.

How to Use OR Logic in an Excel Power Query Conditional Column
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.
Before you start

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.

Solution 1Recommended

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.

1
Create a basic conditional column

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.

2
Open the Formula Bar or Advanced Editor

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.

3
Add the OR operator

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"`.

4
Apply and save

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.

Modify Conditional Column via Formula Bar or Advanced Editor
Case Sensitivity in Power Query: Power Query M language is strictly case-sensitive. Ensure that the 'or' operator is completely lowercase, and that your function names like 'Text.Contains' are properly capitalized.
Free Microsoft Office alternative

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. 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. 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing Excel files directly, without worrying about format conversion issues.
  3. 3. Analyze Your Data: Utilize built-in pivot tables, formulas, and chart tools to process and visualize your data effortlessly.
Highly compatible with Microsoft Excel formats (.xlsx, .xls, .csv) for seamless file sharing.Lightweight design ensuring fast startup and smooth data handling without consuming excessive system resources.Familiar user interface with built-in formulas, pivot tables, and essential data tools.Completely free to download and use for everyday document and spreadsheet processing.
microsoft office alternative - wps office

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`.