Showing posts with label subtotals. Show all posts
Showing posts with label subtotals. Show all posts

Wednesday, March 21, 2012

Grand Total Needed

I have two subreports (Revenue and Expense) that each have subtotals.

This works just fine, but I need a Grand Total that would sum the two subtotals.

How would I go about doing this?

So it looks something like this:

Revenue Report (matrix)

Subtotal

Expense Report (matrix)

Subtotal

<~~~~ Need Grand Total here.

Greg,

It would be difficult across two data regions, myself, I create Calculated GrandTotal field in my dataset and then use that field for display.

Ham

|||

Ok, so say DataSet1 has Total1 and DataSet2 has Total2.

How would I sum the two and display the result at the end of the second report?

|||

Greg,

This should work for you.

Sum(Fields!Counter.Value, "DataSet1")+ Sum(Fields!Counter2.Value, "DataSet2")

Ham

|||

I'm not quite sure how to implement that since my revenue and expense report have a column for each month in the current year.

Maybe I should draw it out a little better:

Revenue Report(matrix)

Jan Feb Mar .........

Account 1 $100 $200

Account 2 $50 $300

Subtotal $150 $500

Expense Report (matrix)

Jan Feb Mar .........

Account 1 $100 $100

Account 2 $0 $300

Subtotal $100 $400

Grand Total $50 $100

I need the Grand Total for each month (subtract Expense subtotal from Revenue subtotal)

|||

Greg,

You will need to use subtraction instead of addition. I was able to get resume for my calculated fields with 2 matrix reports.

Sum(Fields!Income1.Value, "DataSet1") - Sum(Fields!Income1.Value, "DataSet1")

Calculated fields value :=Fields!Income.Value and Income

Calculated fields value :=Fields!Income.Value and Income2

Ham

|||Where would I need to place that code so that it will give the grand total for each month?|||

Greg,

I added a textbox to the bottom of my 2 matrix to make my Grand total align correctly.

Ham

|||

Greg,

Is there a reason why you need 2 matrices? Could you have used 1 Matrix and then selected Expense type field to distingish what totals were being calculated. It much easlier to calculated within a Data Region and to calculated across data regions.

Just thought I would ask.

Ham

|||I used two matrices because the SQL statement to combine Revenue with Expense would be too complex.|||

Could you use a UNION ALL statement with the 2 dataset you are now using. You then could group by expenses, expense type

That would get you the subtotal expense type

and the Grand Total expenses.

|||I'll try it and let you know. Thank you for all of the help by the way!|||

I see that other people in the forums are using UNION ALL. But when I put UNION ALL between the two SQL queries I have, "ALL" is not recognised as a keyword. I get a SQL error near UNION.

I tried the same in SQL 2005 itself and received the same error.

select BLAH,BLAH,BLAH
FROM BLAH,BLAH

WHERE BLAH AND BLAH AND BLAH

GROUP BY BLAH, BLAH, BLAH
ORDER BY BLAH

UNION ALL

select BLAH,BLAH,BLAH

FROM BLAH,BLAH
WHERE BLAH AND BLAH AND BLAH

GROUP BY BLAH, BLAH, BLAH

I get a SQL error: incorrect syntax near the keyword 'UNION'. Both of these queries work fine individually.

|||

Greg,

Your order and group by use by like to following:

select BLAH,BLAH,BLAH
FROM BLAH,BLAH

WHERE BLAH AND BLAH AND BLAH

UNION ALL
select BLAH,BLAH,BLAH

FROM BLAH,BLAH
WHERE BLAH AND BLAH AND BLAH

GROUP BY BLAH, BLAH, BLAH
ORDER BY BLAH

|||

GregSQL wrote:

Revenue Report

Jan Feb Mar .........

Account 1 $100 $200

Account 2 $50 $300

Subtotal $150 $500

Expense Report

Jan Feb Mar .........

Account 1 $100 $100

Account 2 $0 $300

Subtotal $100 $400

Grand Total $50 $100

Ok I have the Grand Total by combining the datasets for Revenue and Expense into one dataset.

Now I'm not sure how to add the subtotals back. There should be a subtotal for Revenue and one for Expense.

Grand Total in Matrixes

Hi,
I am working on matrix report that uses 3 matrixes like below.
In Grand Total matrix, I want to sum matrix 1 and matrix2 subtotals and
display as Grand Total. I had a difficulty to find out the expression for
this(how to reference the subtotals in matrixes?)?
Can we do this or any limitations?
Matrix 1:
Week1 Week2
Sub Total 10 20
Matrix 2:
Week1 Week2
Sub Total 15 25
Grand Total
Week1 Week2
Grand Total 25 45
Any pointers in this regard is appreciated
Thanks
BhaskarOn Nov 16, 5:08 pm, Bhaskar <Bhas...@.discussions.microsoft.com> wrote:
> Hi,
> I am working on matrix report that uses 3 matrixes like below.
> In Grand Total matrix, I want to sum matrix 1 and matrix2 subtotals and
> display as Grand Total. I had a difficulty to find out the expression for
> this(how to reference the subtotals in matrixes?)?
> Can we do this or any limitations?
> Matrix 1:
> Week1 Week2
> Sub Total 10 20
> Matrix 2:
> Week1 Week2
> Sub Total 15 25
> Grand Total
> Week1 Week2
> Grand Total 25 45
> Any pointers in this regard is appreciated
> Thanks
> Bhaskar
Since you have multiple columns that have subtotals, you most likely
will want to sum the subtotals together as part of another report
dataset (via a separate stored procedure/query). If there was only one
subtotal column per matrix, you might have been able to reference
aggregates via an expression similar to this.
=Sum(Fields!Week1.Value, "dsMatrix1") + Sum(Fields!Week1.Value,
"dsMatrix2")
Where dsMatrix1 and dsMatrix2 are the example dataset names used for
Matrix1 and Matrix2 respectively.
Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant|||Thanks Enrique. yeah.. i tried to avoid another query or sp to get the grand
total.
looks like there is no other way. :)
Bhaskar
"EMartinez" wrote:
> On Nov 16, 5:08 pm, Bhaskar <Bhas...@.discussions.microsoft.com> wrote:
> > Hi,
> >
> > I am working on matrix report that uses 3 matrixes like below.
> >
> > In Grand Total matrix, I want to sum matrix 1 and matrix2 subtotals and
> > display as Grand Total. I had a difficulty to find out the expression for
> > this(how to reference the subtotals in matrixes?)?
> > Can we do this or any limitations?
> >
> > Matrix 1:
> >
> > Week1 Week2
> > Sub Total 10 20
> >
> > Matrix 2:
> > Week1 Week2
> > Sub Total 15 25
> >
> > Grand Total
> >
> > Week1 Week2
> > Grand Total 25 45
> >
> > Any pointers in this regard is appreciated
> >
> > Thanks
> > Bhaskar
>
> Since you have multiple columns that have subtotals, you most likely
> will want to sum the subtotals together as part of another report
> dataset (via a separate stored procedure/query). If there was only one
> subtotal column per matrix, you might have been able to reference
> aggregates via an expression similar to this.
> =Sum(Fields!Week1.Value, "dsMatrix1") + Sum(Fields!Week1.Value,
> "dsMatrix2")
> Where dsMatrix1 and dsMatrix2 are the example dataset names used for
> Matrix1 and Matrix2 respectively.
> Hope this helps.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>