You want to achieve this through SQL statement, is it correct?
select year, month, prod, count(*) as qty
from mytab
group by year, month, prod
union
select 'Grant', 'Total', 'Over Time', count(*) as qty
from mytab;
Main Topics
Browse All TopicsHi All,
I am having some trouble getting a Grand Total column at the end of my matrix report, such as you get by default in an Excel pivot table.
I have managed so far to add another column that sums up all values across the data range for a particular product code. My intention was to hide all but the last (I did something similar on rows). However you cannot use an expression on the width property for columns, so this will not work.
My report is very standard:
Year
Month (grouped by year)
Product code | Description [qty]
Any suggestions would be appreciated! Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can achieve this as well through sql. For instance, you have a table with the following data
year, month, prod,amount
2007,12,A,20
2008,01,A,30
2008,01,B,20
2008,01,A,40
You want to see a report having year, month, prod_a, prod_b, total_of_ab
select a.year, a.month, a.prod_a, a.prod_b, b.total_of_ab
from (select year, month, sum(case when prod='A' then prod else null end) as prod_a,
sum(case when prod='B' then prod else null end) as prod_b
from mytab
group by year, month) a,
(select year, month, sum(*) as total_of_ab
from mytab
group by year, month) b
where a.year = b.year
and a.month = b.month;
If you give more details on your table, I might be able to help you more.
Hi geotiger,
Your example table is essentially what I am using. If I understand how to apply the principle to this simple case I can then easily apply it to my table.
I am looking to have a total for each product (i.e row) in a column at the very far right. Essentailly a total for all dates.
I am not sure how to create the matrix using the output of your query to achieve this. From the SQL it looks like you are creating a total across products for each date, not a total across all dates for each product. I may be wrong ;-)
Assuming the table you have above, could you please explain how to build the matrix? Thanks for your time.
Hi,
I have accepted cs97jim's answer as it was the one that (by proxy) mentioned subtotaling on column groups.
It was a simple matter of adding a subtotal to my Year Grouping. I am certain I tried this before and got some very strange behaviour from the rendered report, therefore I came here looking for a solution. Whilst explaining to my colleague with the words "look how this subtotal does not do what you think it would....." I viewed the resulting report (behaving exactly as I had been complaining it wouldn't for the past few days)my colleague commented with "yeah, and......?". Exactly.
Business Accounts
Answer for Membership
by: cs97jjm3Posted on 2008-01-14 at 01:25:05ID: 20651876
http://forums.microsoft.co m/MSDN/Sho wPost.aspx ? PostID=21 11007&Site ID=1