07.4OR and ||
In Excel
| Excel | OR |
|---|---|
| Match |
Sometimes, a single condition met is enough for you. OR and || answer TRUE as soon as one of the conditions answers TRUE. They complete AND and &&, and they hold a trap when you mix them.
Your management, for example, follows two zones, the United States and Canada. A customer is in the United States if they are in New York or in Chicago. Just one of the two conditions is enough.
07.4.1One condition out of two is enough
OR and || answer TRUE if at least one of the two conditions answers TRUE.
Let us add to the Customers table the zone of each customer:
Zone = IF( Customers[City] = "New York" || Customers[City] = "Chicago", "United States", "Canada" )| Customer ID | City | Zone |
|---|---|---|
| C001 | New York | United States |
| C002 | New York | United States |
| C003 | New York | United States |
| C004 | Chicago | United States |
| C005 | Chicago | United States |
| C006 | Toronto | Canada |
| C007 | Toronto | Canada |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
The customers in New York and those in Chicago answer TRUE to one of the two conditions. Only the two customers in Toronto answer FALSE to both.
The same column can also be written with OR, which takes the two conditions between its parentheses, in place of ||:
The result is the same as with ||, five customers in “United States” and two in “Canada.” Choose the one that reads best to you.
OR accepts only two conditions. With three conditions or more, chain || instead, or place one OR inside another OR.
Practice
Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.
Direct useCalculated columnDifficulty
A sports club gives a reduced rate to people under 18 and to students. Add to the “Members” table the calculated column “Reduced Rate,” which shows “Yes” or “No.”
Members Name Age Status Inès 16 Employee Hugo 22 Student Jade 40 Employee Which formula should you write for “Reduced Rate”?
Combined useMeasureDifficulty
A weather station is on alert when it is at least 35 degrees, or when the wind reaches 90 km/h. The “Degrees” and “Wind” columns of the “Readings” table give these values for each day. Write the “Alert Days” measure, shown in a card, the number of days when one of the two conditions is met.
Readings Day Degrees Wind 8/10/2026 36 20 8/11/2026 25 95 8/12/2026 28 40
07.4.2The four possible cases
“Or” answers FALSE in only one case, when both conditions answer FALSE:
| Condition 1 | Condition 2 | Condition 1 || Condition 2 |
|---|---|---|
| TRUE | TRUE | TRUE |
| TRUE | FALSE | TRUE |
| FALSE | TRUE | TRUE |
| FALSE | FALSE | FALSE |
07.4.3IN, for several values of the same column
IN, seen in “Six basic functions,” can also be written in IF. When all the conditions apply to the same column, IN saves you from repeating it. The column is written once, followed by IN and the values between curly braces:
Zone = IF( Customers[City] IN { "New York", "Chicago" }, "United States", "Canada" )| Customer ID | Name | City | Zone |
|---|---|---|---|
| C001 | Orvane | New York | United States |
| C002 | Kumora | New York | United States |
| C003 | Talvio | New York | United States |
| C004 | Ribelia | Chicago | United States |
| C005 | Movara | Chicago | United States |
| C006 | Northel | Toronto | Canada |
| C007 | Sam Lee | Toronto | Canada |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
The result is the same as with ||, five customers in “United States” and two in “Canada.”
07.4.4Mixing “and” and “or”
In the same condition, && comes before ||, just as multiplication comes before addition. This condition therefore reads “a price of 50,000, or else a price of 25,000 with more than 8 cars”:
It answers TRUE for the four sales at a price of 50,000, and for V001, at a price of 25,000 with 10 cars, that is five sales.
To require more than 8 cars in both cases, place parentheses around the “or”:
The sales at a price of 50,000 have only 2 or 3 cars. Only V001 answers TRUE.
As soon as “and” and “or” are mixed, parentheses make the condition clear, even when they change nothing.
Quiz
The questions often rely on the course tables. Keep them in view in their floating window, which you can move and enlarge.
Question 1
What does COUNTROWS( FILTER( Sales, Sales[Price] = 10000 || Sales[Price] = 50000 && Sales[Qty] >= 10 ) ) return?
Question 2
You add to Sales the column Follow-up = IF( Sales[Qty] >= 10 || Sales[Price] = 50000, "Yes", "No" ). How many rows get “Yes”?
Question 3
What does CALCULATE( SUM( Sales[Amount] ), Customers[City] IN { "Chicago", "Toronto" } ) return?
- OR and || answer TRUE as soon as one of the conditions answers TRUE.
- OR accepts only two arguments. || chains as many conditions as you want.
- For several values of the same column, IN saves you from repeating the column, as in Customers[City] IN { "New York", "Chicago" }.
- && comes before ||. Parentheses make the condition clear.