Link to home
Start Free TrialLog in
Avatar of cyberkiwi
cyberkiwiFlag for New Zealand

asked on

Minimum across range with condition ("MINIF")

Can anyone give me a formula that will work like SUMIF, but instead of giving the SUM, gives the MIN instead, all [other] things being equal?

Example:
=SUMIF(A:A,A7,Q:Q)    << returns the sum of values in column Q
                                            where value in column A = A7

I need to:
return the minimum of values in column Q
where value in column A = A7

Which version of Excel? 2010
What type of solution? Formula (not VBA)
What is your proficiency in Excel? Adequate
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

You should try an array formula

=min(if(A:A=A7,Q:Q))

Array formulas should be entered by pressing ctrl-shift-enter

The correctness of the formula entry will be confirmed if you see braces {} around the formula in the formula bar.

If not then select the formula cell
press F2
press ctrl-shift-enter
Avatar of cyberkiwi

ASKER

This is actually across schedule data, so times are involved. {MIN(IF..} gives me 0 (12am) for most of my data which looks like this:
 GroupID \ Arrival \ Departure
 A                   10:30
 B                   11:30
 B         12:30     13:00
 B         15:10          
 C                   10:30
 C         19:45          

Open in new window

I am trying to get, for each group, the start and end times.

Besides, using the array formula (in raw form, i.e. entire column "A:A" instead of say INDIRECT/OFFSET 30 columns above and below) kills my Core i5 (2-core hyperthreaded) workstation for half a minute each time a value changes.
SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't think it is there.
Hello Cyberkiwi,

I think the only "generic MINIF" is the version that Saqib has already provided, you need to exclude blanks (because Excel regards those as zero) but this version would also exclude errors

=MIN(IF(ISNUMBER(RANGE),IF(RANGE=Criteria,Range)))

regards, barry
Thanks Barry,

When *you* throw in the towel, I think I can give up.

MIN(<blanks>) => <zero> ?  (you can try on any unused range)

Is it possible to let it remain blank?  Beginning to think that MIN is a lousy tool for this job.
And {array formula} ... is too expensive to even consider.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Depending on how you are presenting your results, you could also use the DMIN function with an associated criteria table.

Thanks
Rob H
The solution from myself is the only one that works sanely (with given limitation) whereas array formulas although theoretically correct are practically useless, even in very small data sets.