Summing on year and text conditions

D

Dave_in_gva

I have a worksheet with date a bottle of wine is drunk (formatted as
yyyy-mm-dd) and another column indicating whether the wine was Red or White
(White exists as White, or White - Sweet Dessert, so the string "Whit*"
captures all White).

I want a count of total reds, whites, and overall total bottles consumed by
year but do not see how to get this yet. For graphing purposes I would like
these three totals to appear as rows under column headings corresponding to
each year and beginning 2007 and going out to 2040. The base worksheet is
automatically refreshed from an internet based source, so it would be nice to
have a formula that works today and throughout the future.

In case the above is not clear, imagine I have:

Consumed Type
2007-06-23 White
2007-09-17 Red
2008-01-17 Red
2008-11-18 Red

I would want this to give

2007 2008 2009
Total Red 1 2 0 (or empty cell, etc)
Total White 1 0
Total 2 2


Thanks,

Dave M
 
M

Max

Assume source data as posted in Sheet1's cols A and B, data from row2 down,
with real dates in A2 down

Then in your Totals sheet, assuming you have the years listed in B1 across
(2007, 2008, etc), with the colours (eg: Red, White) listed in A2 down (ie
w/o the text "Total")

In B2:
=SUMPRODUCT((Sheet1!$B$2:$B$100=$A2)*(YEAR(Sheet1!$A$2:$A$100)=B$1))
Copy across/fill down to populate. Adapt the ranges to suit.
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:21,000 Files:370 Subscribers:66
xdemechanik
 
D

Dave_in_gva

Thanks Max, extremely helpful and works perfectly.

One other nuance, if I may. I would like to graph the total data of wines
consumed by year, but have these histograms show up as negative numbers,
giving me histograms passing below the x axis. Is there a simple way of
converting the totals your formula is giving me to negative numbers?

Thanks again,

Dave M
 
D

Dave_in_gva

Sorry Max....forget my stupid question. Just figured it out myself and did so
by adding =0-(your formula).

Duh....
 
D

Dave_in_gva

Check. Tx again.

In case you have time/interest/ability I have posted another query in this
forum with the title New worksheets in webquery.xls not automatically
refreshing....awaiting help with this eagerly if possible.

Thanks again for your help with this query.

Dave
 
M

Max

In case you have time/interest/ability I have posted another query in this
forum with the title New worksheets in webquery.xls not automatically
refreshing....awaiting help with this eagerly if possible.

Yes, I read it. But I'm not sure if it has something to do with the degree
of calc intensity involved. Sumproduct, especially with large ranges, is
v.calc intensive. Charts are also calc intensive, and could be a
contributing factor. Does it update ok if you try minimizing the sumproduct
ranges and/or if you dissociate/move the charts into separate book (plot
from frozen data). Hang in there awhile for better answers from others in
your new posting. Good luck.
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:21,000 Files:370 Subscribers:66
xdemechanik
---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top