Solved

SSRS 2008r2 Create subtotal for a group using calculated fields to avoid aggragate error

Posted on 2015-01-23
2
249 Views
Last Modified: 2015-01-24
I am receiving the cannot use aggregate function on report item error in SSRS when trying to subtotal a group using calculated fields.  I am having trouble trying to work around this because my row total is a calculation of two calculating expressions, using the ReportItems! fields to get the total.  

To get the row total I have to multiple the total tons by the load rate.  To get the tons, I have to use an expression that takes the actual tons delivered and check to see if it meets the minimum contracted tons for that load.

=IIF(Fields!Weight.Value / 2000 < ReportItems!MinTon.Value, ReportItems!MinTon.Value, Fields!Weight.Value / 2000)

So if the load is 22 tons and the minimum contract tons is 24, the value "24" is placed in textbox1.  if the total tons delivered is 24.5 tons, the value 24.5 tons is placed in textbox1.

to get the billing total of that load, I use the expression

=ReportItems!Textbox1.Value * Fields!Rate.Value     which puts the value in textbox2.  


Each Row is placed in a group based on the type of commodity.  I need a subtotal by commodity in the group.

So when I SUM(ReportItems!Textbox2.Value)  I get the same old aggregate error

I am not sure how to fix this because I am not able to use the IIF function in a calculated field to get each row total and change the ReportItems! to a Fields!.  

any ideas

Thank you.
0
Comment
Question by:rtay
2 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 40568164
Have you thought of writing a stored procedure the do the first step of calculations? It could then supply your report with (Item times rate) as a single value. Then you could do the single allowed level of calculation that you desire on the report.

hth

Mike
0
 
LVL 5

Author Comment

by:rtay
ID: 40568572
I tried everything.....but that.  Helps to have someone point to the obvious.  Sounds like it should work.  Thanks
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax error with Dates where clause 10 49
backup and restore 21 30
Query for timesheet application 3 19
xml files 7 29
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

830 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