Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default conditional sum macro

Hello - I am trying to generate a report based on some usage reports. I
have three columns, one with user names, one with usage description and
the final with corresponding usage quantity. Some of the usage
descriptions are synonymous so the usage quantity will be a sum of
synonymous categories. For example:

A B C
Green X 4
Green Y 10
Green Z 5
Smith X 3
Smith Y 5
Smith Z 2

In this example, column B has the usage description and for our report
we see X & Y as synonymous -- we would like to see usage results that
are the sum of these. E.g.

Green X/Y 14
Green Z 10
Smith X/Y 8
Smith Z 2
Etc.

This seems like a pretty straightforward =SUMIF problem
[=SUM(IF(A1:A$="Smith",IF(B1:B$="X,Y",C1:C$,0),0))] BUT there is of
course a caveat... The list of names is over 100 and I'd prefer to NOT
declare each one. Is there a way that I can use this formula where I
look for unique values in column A to groupby and then sum accordingly?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default conditional sum macro

You could use SUMPRODUCT
See explanations at
http://www.xldynamic.com/source/xld.SUMPRODUCT.html
http://mcgimpsey.com/excel/formulae/doubleneg.html

I used 6 rows to check my formulas, just change row numbers as needed.
You CANNOT use entire row (A:A) with SUMPRODUCT

Without the synonym problem to start with,
use =SUMPRODUCT(--(A1:A6="Green"),--(B1:B6="X"),C1:C6)
When X and Y are to be aggregated
=SUMPRODUCT(--(A1:A6="Green"),((B1:B6="X")+(B1:B6="Y")),C1:C6)
or
=SUMPRODUCT(--(A1:A6="Green"),--(B1:B6="X"),C1:C6)+SUMPRODUCT(--(A1:A6="Green"),--(B1:B6="Y"),C1:C6)

But you do not want to enter names. Use a Pivot Table.
To overcome X=Y
(a) Use a helper column with =IF(OR(A1="X",A1="Y"), "X", A1)
or (b) extract data from pivot table, adding the X and Y columns


Not really a "macro" so why asked in this newsgroup rather than
Worksheetfunctions ?
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

wrote in message
oups.com...
Hello - I am trying to generate a report based on some usage reports. I
have three columns, one with user names, one with usage description and
the final with corresponding usage quantity. Some of the usage
descriptions are synonymous so the usage quantity will be a sum of
synonymous categories. For example:

A B C
Green X 4
Green Y 10
Green Z 5
Smith X 3
Smith Y 5
Smith Z 2

In this example, column B has the usage description and for our report
we see X & Y as synonymous -- we would like to see usage results that
are the sum of these. E.g.

Green X/Y 14
Green Z 10
Smith X/Y 8
Smith Z 2
Etc.

This seems like a pretty straightforward =SUMIF problem
[=SUM(IF(A1:A$="Smith",IF(B1:B$="X,Y",C1:C$,0),0))] BUT there is of
course a caveat... The list of names is over 100 and I'd prefer to NOT
declare each one. Is there a way that I can use this formula where I
look for unique values in column A to groupby and then sum accordingly?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default conditional sum macro

I would suggest using a pivot table. (this would produce all the
combinations when used with the next suggestion)

In the base data, I would create a dummy column that combines categories
using a formula/lookup table.

--
Regards,
Tom Ogilvy



" wrote:

Hello - I am trying to generate a report based on some usage reports. I
have three columns, one with user names, one with usage description and
the final with corresponding usage quantity. Some of the usage
descriptions are synonymous so the usage quantity will be a sum of
synonymous categories. For example:

A B C
Green X 4
Green Y 10
Green Z 5
Smith X 3
Smith Y 5
Smith Z 2

In this example, column B has the usage description and for our report
we see X & Y as synonymous -- we would like to see usage results that
are the sum of these. E.g.

Green X/Y 14
Green Z 10
Smith X/Y 8
Smith Z 2
Etc.

This seems like a pretty straightforward =SUMIF problem
[=SUM(IF(A1:A$="Smith",IF(B1:B$="X,Y",C1:C$,0),0))] BUT there is of
course a caveat... The list of names is over 100 and I'd prefer to NOT
declare each one. Is there a way that I can use this formula where I
look for unique values in column A to groupby and then sum accordingly?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default conditional sum macro

I just created a pivot table that does what you want. Insert a "calculated
formula" equal to X+Y and hide the X and Y fields and it should work for
you.

hth,

Doug


wrote in message
oups.com...
Hello - I am trying to generate a report based on some usage reports. I
have three columns, one with user names, one with usage description and
the final with corresponding usage quantity. Some of the usage
descriptions are synonymous so the usage quantity will be a sum of
synonymous categories. For example:

A B C
Green X 4
Green Y 10
Green Z 5
Smith X 3
Smith Y 5
Smith Z 2

In this example, column B has the usage description and for our report
we see X & Y as synonymous -- we would like to see usage results that
are the sum of these. E.g.

Green X/Y 14
Green Z 10
Smith X/Y 8
Smith Z 2
Etc.

This seems like a pretty straightforward =SUMIF problem
[=SUM(IF(A1:A$="Smith",IF(B1:B$="X,Y",C1:C$,0),0))] BUT there is of
course a caveat... The list of names is over 100 and I'd prefer to NOT
declare each one. Is there a way that I can use this formula where I
look for unique values in column A to groupby and then sum accordingly?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default conditional sum macro

thanks for everyones help. The pivot table works great for this data.
The only caveat now is this:

my user data is supplied on a monthly basis - so I've created monthly
pivot table / reports. I've been looking around this board to figure
out how to combine these months to generate quarterly, semi anual, etc.
reports. In particular, it would be nice to see what individual users
are doing over a series of months. It looks like I can COMBINE these
reports as long as the fields are the same, BUT I want to keep the data
associated with the worksheet which in this case is associated with the
month.

When I try to setup a new pivot table / report from "multiple
consolidation ranges" I browse for the appropriate work sheets and then
get an error... Maybe I'm doing this wrong. Perhaps the data should
not be structured? Any advice / help is greatly appreciated.

Thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default conditional sum macro

Hi,

Take a look at Debra's brilliant site
http://www.contextures.com/xlPivot08.html

HTH
Cheers
Carim

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
Conditional Macro Stacey Excel Discussion (Misc queries) 2 March 7th 07 05:31 PM
[B]Conditional Macro?[/B] Heydilbert Excel Discussion (Misc queries) 1 November 11th 05 10:07 PM
conditional sum and macro Francine Otterson Excel Discussion (Misc queries) 1 June 22nd 05 09:44 AM
conditional macro eofeapr Excel Programming 4 April 3rd 05 10:41 AM
Conditional Macro Shelley Shepherd via OfficeKB.com Excel Worksheet Functions 1 February 1st 05 05:32 PM


All times are GMT +1. The time now is 08:28 AM.

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

About Us

"It's about Microsoft Excel"