Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

I need to find a way to reference a subtotal relative to one of it's lines.

Example
Product # Salesperson Quanity
Percentage
1 Amy 10
**
1 Ron 20
**
1 Jim 25
**
Product # 1 Total 55
2 Amy 15
**
2 Ron 15
**
2 Jim 35
**
2 Bill 20
**
Product # 2 Total 85
3 Jim 35
**
3 Bill 20
**
Product # 3 Total 55

I of course want to calculate the percentage column by dividing the quantity
by the total. The problem is that the relative position of the total varies.
Is there a way to do this without using code?

Thanks,
Arun
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Duke Carey
 
Posts: n/a
Default Referencing subtotal numbers

Assumes column A has the product # & col B has the Quantity

Also assumes the product # IS a number

=IF(ISNUMBER(A2),C2/SUMIF(A2:A50,A2,C2:C50),"")

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sloth
 
Posts: n/a
Default Referencing subtotal numbers

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

Didn't quite work. The SUMIF function didn't take into account values above
the line it was working on. The final spreadsheet came out like this.

Product # Salesperson Quanity Percentage
1 Amy 10 25%
1 Ron 20 67%
1 Jim 10 100%
Product # 1 Total 55
2 Amy 15 18%
2 Ron 15 21%
2 Jim 35 64%
2 Bill 20 100%
Product # 2 Total 85
3 Jim 35 64%
3 Bill 20 100%
Product # 3 Total 55


"Duke Carey" wrote:

Assumes column A has the product # & col B has the Quantity

Also assumes the product # IS a number

=IF(ISNUMBER(A2),C2/SUMIF(A2:A50,A2,C2:C50),"")

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Duke Carey
 
Posts: n/a
Default Referencing subtotal numbers

My error - should have been

=IF(ISNUMBER(A2),C2/SUMIF(A$2:A$50,A2,C$2:C$50),"")


"Arun" wrote:

Didn't quite work. The SUMIF function didn't take into account values above
the line it was working on. The final spreadsheet came out like this.

Product # Salesperson Quanity Percentage
1 Amy 10 25%
1 Ron 20 67%
1 Jim 10 100%
Product # 1 Total 55
2 Amy 15 18%
2 Ron 15 21%
2 Jim 35 64%
2 Bill 20 100%
Product # 2 Total 85
3 Jim 35 64%
3 Bill 20 100%
Product # 3 Total 55


"Duke Carey" wrote:

Assumes column A has the product # & col B has the Quantity

Also assumes the product # IS a number

=IF(ISNUMBER(A2),C2/SUMIF(A2:A50,A2,C2:C50),"")

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

Wow, it works! But tell me, what do those double negative signs do?

"Sloth" wrote:

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

Also, is there a more elegant way of replacing all the #DIV/0! errors with
zeros than using an IF(....) statement?

"Sloth" wrote:

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sloth
 
Posts: n/a
Default Referencing subtotal numbers

SUMPRODUCT ignores any nonnumerical value. the -- converts the logical
values (TRUE and FALSE) to ones and zeros.

"Arun" wrote:

Wow, it works! But tell me, what do those double negative signs do?

"Sloth" wrote:

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sloth
 
Posts: n/a
Default Referencing subtotal numbers

not that I know of. give me an example of a line that gives the error and I
will try and make a small formula for you.

"Arun" wrote:

Also, is there a more elegant way of replacing all the #DIV/0! errors with
zeros than using an IF(....) statement?

"Sloth" wrote:

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Arun
 
Posts: n/a
Default Referencing subtotal numbers

No big deal. I just didn't want it to do the SUMPRODUCT search twice in each
cell since there are over a thousand lines of data. For example if product 1
had zeros for all the salespeople, it would have to search through all the
data to first check if it adds to zero, and if not, search through it a
second time to get the value to be used in the formula.

Come to think of it, I could just write IF(C2=0,0,C2/SUMPRODUCT(...)). In
other words, if the value is not zero then the sum must be over non-zero. If
it is zero, then it's zero anyway.

Thanks again for all your help.

"Sloth" wrote:

not that I know of. give me an example of a line that gives the error and I
will try and make a small formula for you.

"Arun" wrote:

Also, is there a more elegant way of replacing all the #DIV/0! errors with
zeros than using an IF(....) statement?

"Sloth" wrote:

=C2/SUMPRODUCT(--($A$2:$A$13=A2),$C$2:$C$13)

Copy down and format as a percentage. This assumes "Product #" is in cell
A1. It will look like this..

Product # Salesperson Quanity Percentage
1 Amy 10 25.00%
1 Ron 20 50.00%
1 Jim 10 25.00%
Product # 1 Total 55 100.00%
2 Amy 15 17.65%
2 Ron 15 17.65%
2 Jim 35 41.18%
2 Bill 20 23.53%
Product # 2 Total 85 100.00%
3 Jim 35 63.64%
3 Bill 20 36.36%
Product # 3 Total 55 100.00%

The totals show 100% you will probably want to delete them.

"Arun" wrote:

My table didn't format well after posting. I reformatted it below.

Product # Salesperson Quanity Percentage
1 Amy 10 **
1 Ron 20 **
1 Jim 10 **
Product # 1 Total 55
2 Amy 15 **
2 Ron 15 **
2 Jim 35 **
2 Bill 20 **
Product # 2 Total 85
3 Jim 35 **
3 Bill 20 **
Product # 3 Total 55

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 - pivot table - or better function klafert Excel Worksheet Functions 0 June 16th 05 06:12 AM
Checking Winning Numbers in the Lottery. Ann Excel Discussion (Misc queries) 4 May 18th 05 10:55 AM
Subtotal Bug in Excel 2003 GON Excel Discussion (Misc queries) 2 May 10th 05 08:42 PM
Sorting when some numbers have a text suffix confused on the tundra Excel Discussion (Misc queries) 5 December 18th 04 10:19 PM


All times are GMT +1. The time now is 07:04 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"