#1   Report Post  
M.Siler
 
Posts: n/a
Default Conditional SUBTOTAL

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can I
specify I only want the SUBTOTAL function to consider items in the range
that match a corresponding value in the B column. For example if I have the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at corresponding
Red values such that the result should be 5 as it would only be looking at
A1, A3 & A4. This would permit me to find the highest value in the range of
A1:A5 that were of Red.


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Is there a reason you didn't use the simpler:
=max(a1:a5)

If there is no reason, maybe you could just use:
=MAX(IF(B1:B5="red",A1:A5))
This is an array formula. Hit ctrl-shift-enter instead of enter. If you do it
correctly, excel will wrap curly brackets {} around your formula. (don't type
them yourself.)

You may want to consider using a pivottable.

You'll be able find all the maximums without writing individual formulas.

"M.Siler" wrote:

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can I
specify I only want the SUBTOTAL function to consider items in the range
that match a corresponding value in the B column. For example if I have the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at corresponding
Red values such that the result should be 5 as it would only be looking at
A1, A3 & A4. This would permit me to find the highest value in the range of
A1:A5 that were of Red.


--

Dave Peterson
  #3   Report Post  
M.Siler
 
Posts: n/a
Default

A B C
1 Count Team Month
2 5 Red January
3 7 Blue January
4 12 TOTAL
5 3 Red February
6 4 Red February
7 6 Blue February
8 13 TOTAL
9
10 #VALUE! Max for RED
11 #VALUE! Max for BLUE

Where I defined a name range for the Teams as TeamRange =B2:B3,B5:B7
Where I defined a name range for the Count as CountRange =A2:A3,A5:A7

I tried the formula in A10 as =MAX(IF(TeamRange="Red",CountRange))
I tried the formula in A11 as =MAX(IF(TeamRange="Blue",CountRange))
I entered the formula as an array with Ctrl+Shift+Enter but I get #VALUE! as
it doesn't like the fact the range is not contiguous.

To answer the question about using SUBTOTAL and MAX was because I have
turned on DataFilterAutoFilter and I want the values calculated by the
formula to only calculate on the visible items.

It might be easier if I was to post the workbook on my website... I'll
include the link in the next post -- in about 15 minutes from this one.

Thanks!


"Dave Peterson" wrote in message
...
Is there a reason you didn't use the simpler:
=max(a1:a5)

If there is no reason, maybe you could just use:
=MAX(IF(B1:B5="red",A1:A5))
This is an array formula. Hit ctrl-shift-enter instead of enter. If you
do it
correctly, excel will wrap curly brackets {} around your formula. (don't
type
them yourself.)

You may want to consider using a pivottable.

You'll be able find all the maximums without writing individual formulas.

"M.Siler" wrote:

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can I
specify I only want the SUBTOTAL function to consider items in the range
that match a corresponding value in the B column. For example if I have
the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at
corresponding
Red values such that the result should be 5 as it would only be looking
at
A1, A3 & A4. This would permit me to find the highest value in the range
of
A1:A5 that were of Red.


--

Dave Peterson



  #4   Report Post  
M.Siler
 
Posts: n/a
Default

http://www.veritasinsurance.com/sample.xls

"M.Siler" wrote in message
m...
A B C
1 Count Team Month
2 5 Red January
3 7 Blue January
4 12 TOTAL
5 3 Red February
6 4 Red February
7 6 Blue February
8 13 TOTAL
9
10 #VALUE! Max for RED
11 #VALUE! Max for BLUE

Where I defined a name range for the Teams as TeamRange =B2:B3,B5:B7
Where I defined a name range for the Count as CountRange =A2:A3,A5:A7

I tried the formula in A10 as =MAX(IF(TeamRange="Red",CountRange))
I tried the formula in A11 as =MAX(IF(TeamRange="Blue",CountRange))
I entered the formula as an array with Ctrl+Shift+Enter but I get #VALUE!
as
it doesn't like the fact the range is not contiguous.

To answer the question about using SUBTOTAL and MAX was because I have
turned on DataFilterAutoFilter and I want the values calculated by the
formula to only calculate on the visible items.

It might be easier if I was to post the workbook on my website... I'll
include the link in the next post -- in about 15 minutes from this one.

Thanks!


"Dave Peterson" wrote in message
...
Is there a reason you didn't use the simpler:
=max(a1:a5)

If there is no reason, maybe you could just use:
=MAX(IF(B1:B5="red",A1:A5))
This is an array formula. Hit ctrl-shift-enter instead of enter. If you
do it
correctly, excel will wrap curly brackets {} around your formula. (don't
type
them yourself.)

You may want to consider using a pivottable.

You'll be able find all the maximums without writing individual formulas.

"M.Siler" wrote:

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can I
specify I only want the SUBTOTAL function to consider items in the range
that match a corresponding value in the B column. For example if I have
the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at
corresponding
Red values such that the result should be 5 as it would only be looking
at
A1, A3 & A4. This would permit me to find the highest value in the
range
of
A1:A5 that were of Red.


--

Dave Peterson







  #5   Report Post  
Domenic
 
Posts: n/a
Default

Try...

D1, copied down:

=MAX(IF(SUBTOTAL(3,OFFSET($C$9:$C$26,ROW($C$9:$C$2 6)-MIN(ROW($C$9:$C$26))
,0,1))*($C$9:$C$26=B1),$D$9:$D$26))

....confirmed with CONTROL+SHIFT+ENTER. Then custom format D1:D3 as
follows...

Format Cells Number Custom Type: [=0]"--";General

Hope this helps!

In article ,
"M.Siler" wrote:

http://www.veritasinsurance.com/sample.xls

"M.Siler" wrote in message
m...
A B C
1 Count Team Month
2 5 Red January
3 7 Blue January
4 12 TOTAL
5 3 Red February
6 4 Red February
7 6 Blue February
8 13 TOTAL
9
10 #VALUE! Max for RED
11 #VALUE! Max for BLUE

Where I defined a name range for the Teams as TeamRange =B2:B3,B5:B7
Where I defined a name range for the Count as CountRange =A2:A3,A5:A7

I tried the formula in A10 as =MAX(IF(TeamRange="Red",CountRange))
I tried the formula in A11 as =MAX(IF(TeamRange="Blue",CountRange))
I entered the formula as an array with Ctrl+Shift+Enter but I get #VALUE!
as
it doesn't like the fact the range is not contiguous.

To answer the question about using SUBTOTAL and MAX was because I have
turned on DataFilterAutoFilter and I want the values calculated by the
formula to only calculate on the visible items.

It might be easier if I was to post the workbook on my website... I'll
include the link in the next post -- in about 15 minutes from this one.

Thanks!


"Dave Peterson" wrote in message
...
Is there a reason you didn't use the simpler:
=max(a1:a5)

If there is no reason, maybe you could just use:
=MAX(IF(B1:B5="red",A1:A5))
This is an array formula. Hit ctrl-shift-enter instead of enter. If you
do it
correctly, excel will wrap curly brackets {} around your formula. (don't
type
them yourself.)

You may want to consider using a pivottable.

You'll be able find all the maximums without writing individual formulas.

"M.Siler" wrote:

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can I
specify I only want the SUBTOTAL function to consider items in the range
that match a corresponding value in the B column. For example if I have
the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at
corresponding
Red values such that the result should be 5 as it would only be looking
at
A1, A3 & A4. This would permit me to find the highest value in the
range
of
A1:A5 that were of Red.

--

Dave Peterson





begin 666 sample.xls
[Image]

end



  #6   Report Post  
M.Siler
 
Posts: n/a
Default

Domenic, Very Nicely Done. I'll break apart the formula and learn from it.
Thank you again!

"Domenic" wrote in message
...
Try...

D1, copied down:

=MAX(IF(SUBTOTAL(3,OFFSET($C$9:$C$26,ROW($C$9:$C$2 6)-MIN(ROW($C$9:$C$26))
,0,1))*($C$9:$C$26=B1),$D$9:$D$26))

...confirmed with CONTROL+SHIFT+ENTER. Then custom format D1:D3 as
follows...

Format Cells Number Custom Type: [=0]"--";General

Hope this helps!

In article ,
"M.Siler" wrote:

http://www.veritasinsurance.com/sample.xls

"M.Siler" wrote in message
m...
A B C
1 Count Team Month
2 5 Red January
3 7 Blue January
4 12 TOTAL
5 3 Red February
6 4 Red February
7 6 Blue February
8 13 TOTAL
9
10 #VALUE! Max for RED
11 #VALUE! Max for BLUE

Where I defined a name range for the Teams as TeamRange =B2:B3,B5:B7
Where I defined a name range for the Count as CountRange =A2:A3,A5:A7

I tried the formula in A10 as =MAX(IF(TeamRange="Red",CountRange))
I tried the formula in A11 as =MAX(IF(TeamRange="Blue",CountRange))
I entered the formula as an array with Ctrl+Shift+Enter but I get
#VALUE!
as
it doesn't like the fact the range is not contiguous.

To answer the question about using SUBTOTAL and MAX was because I have
turned on DataFilterAutoFilter and I want the values calculated by
the
formula to only calculate on the visible items.

It might be easier if I was to post the workbook on my website... I'll
include the link in the next post -- in about 15 minutes from this one.

Thanks!


"Dave Peterson" wrote in message
...
Is there a reason you didn't use the simpler:
=max(a1:a5)

If there is no reason, maybe you could just use:
=MAX(IF(B1:B5="red",A1:A5))
This is an array formula. Hit ctrl-shift-enter instead of enter. If
you
do it
correctly, excel will wrap curly brackets {} around your formula.
(don't
type
them yourself.)

You may want to consider using a pivottable.

You'll be able find all the maximums without writing individual
formulas.

"M.Siler" wrote:

A1=5 B1=Red
A2=7 B2=Blue
A3=2 B3=Red
A4=4 B4=Red
A5=6 B5=Blue

I know if I have SUBTOTAL(4,A1:A5) the result will be 7, but how can
I
specify I only want the SUBTOTAL function to consider items in the
range
that match a corresponding value in the B column. For example if I
have
the
same function, SUBTOTAL(4,A1:A5) but I want it only to look at
corresponding
Red values such that the result should be 5 as it would only be
looking
at
A1, A3 & A4. This would permit me to find the highest value in the
range
of
A1:A5 that were of Red.

--

Dave Peterson




begin 666 sample.xls
[Image]

end



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtotal vs Pivot table - or best way klafert Excel Discussion (Misc queries) 2 June 16th 05 06:29 PM
Subtotal Bug in Excel 2003 GON Excel Discussion (Misc queries) 2 May 10th 05 08:42 PM
Is there a command like subtotal but with a conditional? Hiughs Excel Worksheet Functions 1 March 1st 05 07:24 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM
Is it possible to do a conditional subtotal in Excel? LTS_Bgobien Excel Worksheet Functions 6 November 16th 04 11:12 PM


All times are GMT +1. The time now is 04:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"