# Rookie Questions

• ### Question

• Hi there,

I am new to ReportViewer and I have a rookie question. I need to create a matrix report that shows monthly product sales by product type. Every month's sales sum need to include the sum of the previous months sales sum. I.e of the sales sum for January is 5.000, February is 15.000, and March is 10.000; the report need to display 5.000 for January, 20.000 for February, and 30.000 for March.

Any idea how I can do it?

Thanks,

Sefa

Tuesday, January 8, 2008 6:56 PM

### All replies

• well...the first thing that pops to mind is for January

Fields!January.Value

for February

Fields!January.Value + Fields!February.Value

for March

Fields!January.Value + Fields!February.Value + Fields.March.Value

this is assuming all values are numerical based and of the same datatype

Tuesday, January 8, 2008 10:00 PM
•

Thank you very much for your reponse. The report I created doesn't have fix months, in other words, user selects the date range (i.e. show me all the sales by product type between March 13, 2005 and  February 5, 2007) so I am using subtotals but as I stated earlier, I need to find a way to carry over previous months sales. I apoligize if I wasn't clear enough in my previous post...

Any ideas,

Sefa

Wednesday, January 9, 2008 5:27 PM
• Well, my Field examples were merely just that, examples. Nobody could speculate someone elses data structure very easily.

So here is the question, how do you get the Januarys total? And how do you get February's total? Are you able to do that right now? And if so are  you able to get those totals to the report?   If not, where are these totals being stored at right now?

Wednesday, January 9, 2008 7:49 PM
•

You are right, I should have elicited on my data structure. I've been using the subtotals to get totals and I've been able to get the totals. Hope this clarifies...
Wednesday, January 9, 2008 9:45 PM
• Ok, so your using an expression that uses the Sum Function?

For example   Sum(Fields!Column.Value)

If this is the case then it's just a matter of  writting an expression that add's these sums together.

Wednesday, January 9, 2008 10:26 PM
•

Yes, I've been using the sum function and then I use subtotal for each month. My matrix looks like this

JAN | FEB | MAR

PROD TYPE1      10               20

PROD TYPE2                12     7

PROD TYPE3      15

TOTALS               25      12     27

I try to show the totals as 25, 37, 64.

Sefa

Wednesday, January 9, 2008 11:22 PM
• ok, so you've already done most of the work....

just do this

Sum(Fields!Something.Value) + Sum(Fields!SomethingElse.Value)+ Sum(Fields!AnotherThing.Value)   and so on

This also works

Sum(Fields!Something.Value + Fields!SomethingElse.Value + Fields!AnotherThing.Value)

But I don't recommend using it, because if two of your fields have different data types you'll get an error for not converting them to match....

Thursday, January 10, 2008 3:24 PM