Finding a minimum using conditions and filters

bbhgroup

Board Regular
Joined
Dec 30, 2008
Messages
97
I have three columns of information:
Date, Plant, Load Start (Time)

I allow filters so that the user can select some of the data to evaluate.

I am looking for the Minimum value of Load Start (a time) based on Date and Plant Criteria.
For the following:
DB_DATE is the column array of dates
DB_PL is the column array of Plants
DB_LS is the column array of Load Start
All arrays are the same size.
<date> [date] is the cell with the desired date
[plant]is a cell with the desired plant

This formula works swell but doesn't take filters into account:
<code><code>
=MIN(IF(DB_DATE=<date>[date],IF(DB_PL=[plant],DB_LS)))
</date></code></code>
This array formula only works if the *first* row of the array matches the criteria selected, it otherwise returns 0:
<code><code>
={(SUBTOTAL(5,OFFSET(DB_LS,ROW(DB_LS)-ROW([first row of DB_LS]),,1))*--(DB_PL=[plant])*--(DB_DATE=[date]<date>))}
</date></code></code>
I also tried sumproduct/subtotal with unhappy results, this returns the sum of all the rows that match the criteria instead of the minimum one:
<code><code>
={SUMPRODUCT(SUBTOTAL(5,OFFSET(DB_LS,ROW(DB_LS)-ROW([first row of DB_LS)),,1)),--(DB_PL=[plant]),--(DB_DATE=[date]<date>))}
</date></code></code>

I'm stuck. I really thought the second formula should work but doesn't.</date>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
If you only have three columns, and you're applying the filter on the plant and date columns, try...

=SUBTOTAL(5,DB_LS)

Otherwise, try the following formula that needs to be confirmed with CONTROL+SHIFT+ENTER...

=MIN(IF(DB_PL=[plant],IF(DB_DATE=[date],IF(SUBTOTAL(3,OFFSET(DB_LS,ROW(DB_LS)-MIN(ROW(DB_LS)),0,1))>0,DB_LS))))
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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