Solved

SSRS 2005 Summing Issue

Posted on 2010-09-16
17
504 Views
Last Modified: 2012-05-10
We have products that have a budget amount and count assigned to them and I need to do the normal sums and variance by product and finally by the category that the product belongs to. The problem is that my dataset contains many rows for each product so I went ahead and put the Budget amount on each row and just use First() on the details section of the table but now I have the issue where I need the sum of the First budget amount/counts in the table footer to report at the category level.

Product	Category	        Sale          Budget Cnt	          Budget Amt

123	1		12	1500		10,000	
123	1		10	1500		10,000		
151	2		45	2600		50,000		
123	1		25	1500		10,000	
151	2		62	2600		50,000

Open in new window

0
Comment
Question by:DowntownIT
17 Comments
 
LVL 11

Expert Comment

by:aelliso3
ID: 33694398
Using the part above, can you show an example of what the expected out come is?
0
 
LVL 27

Expert Comment

by:planocz
ID: 33706672
Group by Category, then group2 by Product. Place textboxes in group2 footer and sum the values. You do not need to show a detail row, unless you need too.
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33734822
Planocz,

I am trying what you are suggesting but getting and error. "Aggregate functions can be used only on report items contained in page headers and footers."

I placed a textbox in the group 2 footer and named it sum_txtBx. Now in the group 1 footer I have this expression, =Sum(Reportitems!Sum_txtBx.Value).


Aelliso3, The final result set should be like below. Also, this should be done at the table level if possible.




Category  

    Product    Sale  Budget Cnt.    Budget Amt.

   1

        123    47    1500           10,000



   2

        151    107    2600          50,000



Total          154   4100           60,000

Open in new window

0
 
LVL 27

Expert Comment

by:planocz
ID: 33736157
Each column has to look like this....
                       Sale                           Budget Ct.
                    =Fields!Sales.value       =Fields!Budget.value
Totals        =Sum(Fields!Sales.value)       =Sum(Fields!Budget.value)
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33737074
The sales column needs to be summed and the budget Ct. not summed at the product level.
My dataset contains multiple individual sales to each product that need to be summed at the product level but since the budget is assigned at the product level I can only return the budget amt/cnt as the full value on each individual row in my dataset.

So when I am looking at the totals for a paticluar product, I can use =First(Fields!Budget_Cnt.value) but when I need the totals for a Category, It needs to be the the first budget value from each product in my dataset summed together.

This is what I am looking for,

                                         Product_Name                        Sales                                     Budget

Table Header        =(Fields!Category_Desc.value)

Table Details        =(Fields!Prod_Desc.value)   =Sum(Fields!sales.value)   =First(Fields!Budget.value)  -- The Table Details groups by Prod_Desc

Table Footer                      Totals:                    =Sum(Fields!sales.value)   =Sum(First(Fields!Budget.value)) -- "This does not work"




Thanks for the help.
0
 
LVL 27

Expert Comment

by:planocz
ID: 33737208
You have to use group footers, not table footer.
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33737306
Say I move it to this format,


Grp_1 Header        =(Fields!Category_Desc.value)   -- groups by Category_Desc

Grp_2 footer        =(Fields!Prod_Desc.value)   =Sum(Fields!sales.value)   =First(Fields!Budget.value)  -- groups by Prod_Desc

Grp_1 Footer                      Totals:                    =Sum(Fields!sales.value)   =Sum(First(Fields!Budget.value))


How would you handle the budget value in the Group 1 footer?



Thanks,
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Expert Comment

by:planocz
ID: 33737473
the detail row will be between the grp1 header and grp2 footer should work with the setup you have above
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33737860
I guess I am not following. It is the grp_1 footer that I am have the issue. The expression =Sum(First(Fields!Budget.value))
 is not working for me.

Thanks
0
 
LVL 27

Expert Comment

by:planocz
ID: 33737933
The totals have to be on the last group which is grp2 not grp1
if you want sums for grp1 you will have to add the grp1 footer for those sums.
 
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33738030
Yes, I do want a sum for grp 1 and my issue is that I can not add up the grp 1 footer for the budget column.
0
 
LVL 27

Expert Comment

by:planocz
ID: 33738136
I think you  are wanting...
=First(Fields!Budget.value)  -- Sum(Fields!Prod_Desc.value)
0
 
LVL 2

Author Comment

by:DowntownIT
ID: 33743463
can not sum Fields!Prod_Desc.value, it's only a description field.

=First(Fields!Budget.value) only works at the product level. will not work at the category level.
0
 
LVL 11

Accepted Solution

by:
thman earned 500 total points
ID: 33775089
DowntownIT,
Since your details rows do not list all the rows for the same product and only list the summary, instead of using 2 groups in your layout, you should just use 1 group (category) in the layout and place the product grouping in your command text of the query. When grouping in the query, you sum on sale and counts first and then join with the table that contains budget.
0
 
LVL 2

Author Closing Comment

by:DowntownIT
ID: 33780998
I actually thought of going this route but was hoping that I could keep the procedure returning all details and doing the grouping at the report, this way I could re-use the procedure for other detailed reports.

Now that you mentioned it, it is not a big deal to have two different versions of the procedure.

Thanks,
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now