SSRS expressions SUM between textbox - reporting-services

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.

Related

Expression to calculate % in a report

I am building a report(report server project) using the Data Tools. I have a column Quantity it has a Total.
I need another column that calculate the share(%) of each line in the Quantity comparing to the Total.
The expression would be: Line_1_Share = Quantity_of_line_1/Total.
I tried =[Sum(Total/Quantity)] but it does not even accept as a valid expression.
If you right-click the textboxes that contain your working 'Quantity' and 'Total' values and look at the expressions you will see the correct format.
For exmaple your 'Quantity' expression might be something like
=Fields!Quantity.Value
or if it is in a grouped row it might be
=SUM(Fields!Quantity.Value)
your 'Total' expression might also be
=SUM(Fields!Quantity.Value)
When you use SUM() (or any similar aggregate) then the scope of the expression decides what is included in the sum. The scope can be a single row, a row group or an entire dataset. If you do not specify a scope then the position of the textbox determines the scope.
So, if you have a simple table with no grouping other than the total line and your dataset name is dataset1 then your expression would need to be
=Fields!Quantity.Value / SUM(Fields!Quantity.Value, "dataset1")
The above reads .... "For the current row, take the Quantity and divide is but the sum of all Quantities that are within the entire dataset called dataset1"
If this does not help, post your current report design including and row and/or column groups.

SSRS - add percentage of total?

I am just starting out in SSRS and have a dataset that looks like the below.
I have built this in a matrix table like so
I want to show what percentage each of the rows total is of the grand total, so for the attached image I would want to show what percentage 35 (counselling calls) is of 47 (total) and what percentage Legal calls (12) is of total (47)
I have tried =Fields!Calls.Value/sum(Fields!Calls.Value) but that just gives me 100% for both?
Would appreciate any help
You need to specify the scope of your SUM() expressions.
I'll briefly explain how scopes work and then get to the answer.
SSRS always evaluates an expression based on it's scope which is usually defined by the physical location of the expression within table/matrix. As you can see from your design all 4 textboxes show the same expression, [SUM(Calls}] which in fact is actually =SUM(Fields!Calls.Value). However they give different results because the scope of each is different. The first is in the category rowgroup and the month column group for example, the second one is in the category row group but in the total month group, and so on...
OK, now to the answer !
Assumming
your rowgroup is called 'CategoryGroup` (you will see the name in the rowgroup panel under the main designer)
your dataset is called DataSet1
You expression should be
=SUM(Fields!Calls.Value, "CategoryGroup") / SUM(Fields!Calls.Value, "DataSet1")
This basically reads..
Take the sum of the call column for all rows that are within the current CategoryRowgroup and divide by the sum of the call column across the whole dataset.
Notes
The scope names must be enclosed in quote and are case sensitive
The scope names must match either a row or column group, or a dataset name exactly.
the , "CategoryGroup" scope argument can probably be omitted as this should be the scope of the textbox anyway.

Expression for Calculating a RunningValue column in SSRS Tablix Control

User enters a fixed parameter representing a Credit Limit.
Then each row subtracts a different column called [AmountPaid].
So the Balance Available column show what is left and this gets smaller and smaller down the rows to the bottom.
Both column textboxes in Tablix are set to Number type=Currency. Parameter is set to Float. Not many choices of data type for the Parameter input.
I thought this would work in an expression for the Balance Available but it gives me an error. My idea was to do a running Sum and then subtract it from the initial Credit Limit:
=Parameters!CreditLimit.Value - RunningValue(Fields!AmountPaid, Sum, "DataSet1")
The message for the error is:
[rsAggregateOfInvalidExpressionDataType] The Value expression for the textrun ‘Textbox23.Paragraphs[0].TextRuns[0]’ uses an aggregate function with an expression that returned a data type not valid for the aggregate function.
If this question could be asked differently I am open to suggestions. Thanks
You need to get the value of AmountPaid so try Fields!AmountPaid.Value`

SSRS Visibility Hide iif All

Just wondering if it is possible to do the following on SSRS for a textbox visibility (hide), it seems to return an error for me:
=iif(parameters!category.value = "All",True,False)
I have a long list of category so therefore is impossible to list them all, is it possible to the above? I keep getting an error with the above-outlined syntax
I assume the category parameter is multi-select with available values fed by a SQL query. You can use the Count property on the parameter to get the number of selected items and compare that to the number of items returned by the SQL query using the COUNT() SSRS aggregate function with a scope of the dataset. If the number of selected items matches the number of available values then they must be all selected.
So your code would look like:
=IIF(Parameters!category.Count = COUNT(Fields!CategoryName.Value, "CategoryParameterDataSetName"), True, False)
In this case the dataset that contains all of your available values is named CategoryParameterDataSetName and contains a field named CategoryName. Change these values as appropriate.

SSRS 2005 Divide values of two text boxes

I thought this would be simple, but i must be missing something
here is my expression
=Sum(ReportItems!ID.Value)/Sum(ReportItems!NumberofUnits.Value)
I get this error.
The Value expression for the textbox 'textbox14' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.
I really just want to divide those two report item values.
You cannot use an aggregate function (SUM) on a ReportItem. remember that a ReportItem is a textbox or other object inside the report. So either change your expression to:
ReportItems!ID.Value/ReportItems!NumberofUnits.Value
Or in case your ID and NumberofUnits reportitems are inside the context of a dataset (for example, in a tablix), and both of them corresponds to fields in the dataset, do this:
Sum(Fields!ID.Value)/Sum(Fields!NumberofUnits.Value)
You may optionally specify the scope over which the SUM function should work, by adding the name of the scope (for example dataset name, tablix name, group name) as a 2nd argument to the SUM function.