Conditional Subtotal - Calculate min/max in column A for rows that are not empty in column B?

unclefish

New Member
Joined
Jun 8, 2023
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
Dear Excelists,

I'd appreciate your comments on the following problem:

I do have a data table with the project name in the 1st colum, duration of the problem in the 2nd colum and some parameter in the 3rd colum.

Project
TimeParameter
A220
A4
B1215
A2430
B6040
B12
A48
A425
A4
A8

I want ro review the (min/max) duration of activities for project A or B, but only including those activities that already produced some output (parameter).


For the minimum duration, I'm trying to do this by using the subtotal function =subtotal(105;B2:B11). But when i filter for project A or B, this formula returns the minimum over the entire filtered range.
However i would like to have the minmum or maximum only those cells with non-empty rows in the parameter colum (the cell with bold numbers in the above table).


If done correctly i would only include the cells highlighted in yellow (project A) or blue (project B) in my review (see the attached screenshot).
And i'd obtain the following result:
Project A: min 2, max 24
Project B: min 12, max 60

Any help is highly appreciated!
 

Attachments

  • Excel-Frage.jpg
    Excel-Frage.jpg
    21.3 KB · Views: 5

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi @unclefish
Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.​

I think you do have the maxifs function.

Try this:
Dante Amor
ABCDEFGH
1ProjectTimeParameterProjectMinMax
2A220A224
3A4B1260
4B1215
5A2430
6B6040
7B12
8A48
9A425
10A4
11A8
Sh2


In G2 to G3:
Excel Formula:
=MINIFS($B$2:$B$11,$A$2:$A$11,$F2,$B$2:$B$11,"<>",$C$2:$C$11,"<>")

In H2 to H3:
Excel Formula:
=MAXIFS($B$2:$B$11,$A$2:$A$11,$F2,$B$2:$B$11,"<>",$C$2:$C$11,"<>")

--------------------------​

But if you don't have it, you can use the following:
Dante Amor
ABCDEFGH
1ProjectTimeParameterProjectMinMax
2A220A224
3A4B1260
4B1215
5A2430
6B6040
7B12
8A48
9A425
10A4
11A8
Hoja1
Cell Formulas
RangeFormula
G2:G3G2=MIN(IF($A$2:$A$11=$F2,IF($B$2:$B$11<>"",IF($C$2:$C$11<>"",$B$2:$B$11))))
H2:H3H2=MAX(IF($A$2:$A$11=$F2,IF($B$2:$B$11<>"",IF($C$2:$C$11<>"",$B$2:$B$11))))
Press CTRL+SHIFT+ENTER to enter array formulas.


--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Last edited:
Upvote 0
Hi DanteAmor!

Thank you very much for the warm welcome! And thank you even more for your comment and the provided solution.
But in my case i have to use filters (for too many reasons to be summarized here) so i think i can't use an approach with fixed criteria fields (like those in colum F of you formula).

I do know that i can calculate the min of colum B and only taking into account the rows with non-empty cells in colum C via the MINIFS formula:
Excel Formula:
=MINIFS(B2:B11,C2:C11,"<>")
But this will not change if i apply filters to colum A.
I need a way to combine the minifs function with the subtotal function.
 
Upvote 0
How about a help column?
In cell D1 you write the name of the project.
And in cells H1 and J1 the formulas for min and max:

Dante Amor
ABCDEFGHIJ
1ProjectTimeParameterAMin2Max24
2A2202
3A4FALSE
4B1215FALSE
5A243024
6B6040FALSE
7B12FALSE
8A48FALSE
9A4254
10A4FALSE
11A8FALSE
12
13
14
15
Hoja1
Cell Formulas
RangeFormula
H1H1=SUBTOTAL(105,$D$2:$D$15)
J1J1=SUBTOTAL(104,$D$2:$D$15)
D2:D11D2=IF(AND(A2=$D$1,C2<>"",B2<>""),B2)
 
Upvote 0
With a Table
T202306a.xlsm
ABC
1Max24
2Min2
3ProjectTimeParameter
4A220
7A2430
11A425
13A8
14
2d
Cell Formulas
RangeFormula
B1B1=SUBTOTAL(104,Table2[Time])
B2B2=SUBTOTAL(105,Table2[Time])
 
Upvote 0
If you have the Filter formula in your version of Excel, try the following:

T202306a.xlsm
ABC
15Max24
16Min2
17ProjectTimeParameter
18A220
19A4
20B1215
21A2430
22B6040
23B12
24A48
25A425
26A4
27A8
2d
Cell Formulas
RangeFormula
B15B15=MAX(FILTER(B18:B27,(A18:A27="A")*(C18:C27>0)))
B16B16=MIN(FILTER(B18:B27,(A18:A27="A")*(C18:C27>0)))
 
Upvote 0
Thanks a lot, Dave!
I do understand the idea of a helper column but this approach is not applicable for my case.

The table I posted is just a small piece of a much larger table with multiple other functions. It covers data of almost 30 projects and is frequently updated with new projects/data.
For some reviews i need to include mutiple projects, i also apply multiple filters and so on... all this makes an approach with a fixed criteria cell not feasible.
 
Upvote 0
You could use a helper column like
Fluff.xlsm
ABCDEFGHIJ
1ProjectTimeParameterIsVisibleMin2Max60
2A2201
3A41
4B12151
5A24301
6B60401
7B121
8A481
9A4251
10A41
11A81
Master
Cell Formulas
RangeFormula
H1H1=MINIFS(B2:B100,C2:C100,"<>",D2:D100,1)
J1J1=MAXIFS(B2:B100,C2:C100,"<>",D2:D100,1)
D2:D11D2=SUBTOTAL(103,A2)


Fluff.xlsm
ABCDEFGHIJ
1ProjectTimeParameterIsVisibleMin12Max60
4B12151
6B60401
7B121
Master
Cell Formulas
RangeFormula
H1H1=MINIFS(B2:B100,C2:C100,"<>",D2:D100,1)
J1J1=MAXIFS(B2:B100,C2:C100,"<>",D2:D100,1)
D4,D6:D7D4=SUBTOTAL(103,A4)
 
Upvote 0
Thanks a lot, Dave!
I do understand the idea of a helper column but this approach is not applicable for my case.

I did not use helper columns in either of the suggestions!
Did you try the suggestions?
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

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