Combining multiple OR conditions with AND in Excel formula

sjedi

New Member
Joined
Dec 8, 2019
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
I am trying to combine OR conditions with AND over multiple columns in my Excel datasheet and would like advice on how to do this. A sample table is shown below.

The formula does not calculate the two OR conditions for [Year] and [Season].
Excel Formula:
=MEDIAN(IF((Table1[Fruit]="Apple")*OR(Table1[Year]=2023,Table1[Year]=2024)*OR(Table1[Season]="Summer",Table1[Season]="Spring"),Table1[Value]))

The above formula gives Median = 5. The correct answer is Median = 5.5

SeasonYearFruitValue
Summer2023Apple3
Winter2023Apple5
Spring2023Banana10
Summer2023Banana15
Winter2024Apple50
Spring2024Banana2
Summer2024Apple8
Winter2025Banana12
Spring2023Orange42
Summer2023Orange20
Winter2024Orange9
Spring2025Apple2
Spring2025Banana10


Correct filtering of [Fruit] = Apple, [Year] = 2023 or 2024, [Season] = Summer or Spring:

Median (3,8) = 5.5

SeasonYearFruitValue
Summer2023Apple3
Summer2024Apple8
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Must use "+" for OR as you've used "*" for AND.
Excel Formula:
=MEDIAN(IF((Table1[Fruit]="Apple")*((Table1[Year]=2023)+(Table1[Year]=2024))*((Table1[Season]="Summer")+(Table1[Season]="Spring")),Table1[Value]))
 
Upvote 1

Forum statistics

Threads
1,225,481
Messages
6,185,249
Members
453,283
Latest member
Shortm88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top