SSRS Reports giving me an aggregate error - reporting-services

Trying to do some math in SSRS and getting this error.
The Value expression for the text box ‘totalboxes3’ has an inner aggregate in an outer aggregate that specifies a dataset scope. An aggregate that specifies a dataset scope cannot contain other aggregates.
I am using the expression:
=Sum(Fields!GP_Goal.Value, "Main") / Sum(Sum(Fields!Smartphone_Postpaid.Value) - Sum(Fields!CPE_Postpaid_Only.Value), "Main")
Im very new to SSRS so im trying to understand what this is asking me and how to fix it.
ive also tried
=Sum(Fields!GP_Goal.Value, "Main") / Sum(Sum(Fields!Smartphone_Postpaid.Value, "Main") - Sum(Fields!CPE_Postpaid_Only.Value, "Main"))

The problem is this:
Sum(Sum(Fields!Smartphone_Postpaid.Value) - Sum(Fields!CPE_Postpaid_Only.Value)
The outer SUM isn't needed, just subtract the sums and specify the dataset within the sums:
=Sum(Fields!GP_Goal.Value, "Main") / (Sum(Fields!Smartphone_Postpaid.Value, "Main") - Sum(Fields!CPE_Postpaid_Only.Value, "Main"))

Related

SSRS Expression - Subtracting the Sums, when one group is a parameter

I am trying to Subtract two scenarios from each other in a SSRS report. One scenario is a constant, 'Actuals' the other is a dynamic forecast scenario and set by a parameter. Here is the code I am trying:
=sum(iif(Fields!Scenario_Name.Value=Parameters!ScenarioName.Value,CDbl(Fields!CAD.Value),0))-
sum(iif(Fields!Scenario_Name.Value="Activity Actuals",CDbl(Fields!CAD.Value),0))
I have also tried:
=sum(iif(Fields!Scenario_Name.Value=Parameters!ScenarioName.Value,Fields!CAD.Value,0))-
sum(iif(Fields!Scenario_Name.Value="Activity Actuals",Fields!CAD.Value,0))
The report runs but I get an error in the line where this expression is entered.
The CDEC was important to both the CAD.value and the 0. The Parameter value needs a (0) as in the final expression that works.
enter code here=Sum(IIf(Fields!Scenario_Name.Value=Parameters!ScenarioName.Value,CDEC(Fields!CAD.Value),CDEC(0))) -
Sum(iif(Fields!Scenario_Name.Value="Activity Actuals",CDEC(Fields!CAD.Value),CDEC(0)))

SSRS expressions SUM between textbox

I'm trying to calculate an expression to SUM two ssrs textboxes but then I get the following error:
The Value expression for the textrun ‘Textbox343.Paragraphs[0].TextRuns[0]’ contains an error: [BC30456] 'textbox346' is not a member of 'Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.ReportItems'.
The error message says that the control textbox346 can't be found. As you say that you try to calculate a SUM on this textbox, you probably want to do this in a group header or footer, but on that level, you can't access a report item (a textbox) on a lower level (a details row), because there can be many of them.
Also: Aggregate functions (like SUM) can't operate on expressions that refer to report items. The values in such expressions must depend just on the dataset. The amount of data can be controlled by grouping the tablix and using a scope for the function.
Therefore, if your textbox textbox346 (on the group details level) is bound to an expressions depending on just dataset fields, use that same expression in your SUM furmula in Textbox343 (in the group header or footer).
could you just sum it in sql? it's often easier to just avoid the error by summing it up in the dataset.

SSRS calculation expression for specific value

I'm looking at doing a calculation expression in SSRS but I've become unstuck.
I'm trying to calculate when a field equals a specific value, then return a percentage calculation.
This is what I've tried so far:
=SUM(IIF(Fields!Alert.Value="Red",(FormatPercent(Count(Fields!Sales.Value) / 6532 ,0)))SUM(IIF(Fields!Alert.Value="Yellow",(FormatPercent(Count(Fields!Sales.Value) / 2541 ,0)))SUM(IIF(Fields!Alert.Value="Green",(FormatPercent(Count(Fields!Sales.Value) / 1025,0)))
Obviously this is incorrect and doesn't work. The expression needs to include all 3 colours.
UPDATED see if this works.
UPDATED per requested. I put the statement in the last False part, but I'm not sure if this is what you really want.
UPDATED again. Added False part to the last IIF statement.
UPDATED: Removed the SUM function. Try this to see if it works. Your IIF statement didn't have any False parts. Also, just SUM once around the whole statement if you want it summed. Not knowing your data, I'm not sure if you want the % summed up.
=IIF(Fields!location.Value="East" AND Fields!Alert.Value="Red",(FormatPercent(Count(Fields!Sales.Value) / 6532 ,0)),IIF(Fields!Alert.Value="Yellow",FormatPercent(Count(Fields!Sales.Value) / 2541 ,0),IIF(Fields!Alert.Value="Green",FormatPercent(Count(Fields!Sales.Value) / 1025,0),0)))

error : nested aggregation that specifies a dataset scope

I have been working on ssrs and tried to do the following statement. I am using data from 2 datasets and there is no way I can merge them into one (I tried that when I first had this error). Code:
=Sum(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
This code gives the error: The Value expression for the text box has a nested aggregate that specifies a dataset scope. Inner aggregates cannot specify a dataset scope.
I have also tried a different variation of this code which is as follows:
=(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
I just got rid of the sum at the beginning. But this time I had a different error: Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case
Hope someone can help :)
Cheers
Your expression is a bit wrong.
=Sum(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
Your Sum is outside and is covering the two fields which is not on the same dataset. You should assign Sum for each of them since they are from different dataset.
Try this:
=iif(Sum(Fields!Year.Value) = Max(Sum(Fields!Year.Value)) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0)
Note: I haven't tested the Max(Sum(.... if that's correct.

SSRS 2005 Matrix Reports - Editing Total

This seems as though it should be simple, but appears not to be.
In SSRS 2005 I've written a matrix report and added some fields, one of which has the formula: If (x / y >= n, 1, 0). I've called this field 'Accuracy'. The report aggregates this field across a number of individuals and then for a number of days.
Ideally I want a subtotal that gives a sum of the 'Accuracy' figures (so we can say we had n people who were accurate today). However, the subtotal calculates the formula for the totals of x and y. Subtotals is only ever going to be 1 or 0.
Any ideas as to how I can get a Count of Accuracy displayed on the matrix report? I've tried creating various fields along the lines of Sum(accuracy) and Count(accuracy) - these return an error when the report is run.
Thanks!
maybe report behaves 0 and 1 as a boolean value. you can make a dll that do this work for you and reference to your report and use the methods that exist for this work in dll.
Try using the running value. You could put the expression inside it or inside the report code block and just call it.
=RunningValue(what to count, sum, scope)
=RunningValue(Fields!Cost.Value, Sum, Nothing)
More info here:
http://msdn.microsoft.com/en-us/library/ms159136.aspx
Hope it helps.