Expression for Calculating a RunningValue column in SSRS Tablix Control - reporting-services

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`

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)))

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 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 fills in arbitrary value when no result is returned in query

I have a report with column and row groups to calculate inventory.
there are some items in a column group that do not have any results in the query.
for example, item 009000 does not have any inventory entries in FY2016, I checked the query and indeed, there is nothing in it for that item in FY2016.
the report fills something in however and fills in the same value for every empty result. Even more confusing, this arbitrary value changes if I refresh the report. I want this field empty, I've used IsNothing and <> '' and <> 0 but to no avail, it always fills something in (second screenshot). I'm so confused. I have no idea what could be causing it, there is no calculation in the field. (first screenshot)
Change expression for example, if you have numeric field then use expression =Sum(Inventory.value) instead of =Inventory.value
s

SSRS. Hide a Column based on Row Group Value

My application uses SSRS to produce payslips for employees. The Payslip report consists of a tablix with 5 columns. Among the 5, is a column called "Units" and another called "Invoice value".
The report has several Row Grouping levels, but the only important one for this question is the Payslip Number Row Grouping "RG_SlipNum". There is a page break after each "RG_SlipNum" RowGroup.
When users want to print Payslips, they can optionally supply up to 5 parameters which filter the result set to print out.
Employees can be paid based on the number of units delivered * a rate (Unit Based), or by a percentage of the invoice value (Invoice based) for the delivery (Oversimplified, but hopefully, you get my drift).
If the employee is Unit based I want the Units Column to Show, and the "Invoice Value" Column to be hidden. If they are Invoice based I want both columns to show.
My dataset has a bit field indicating whether to show or hide a column based on the logic above. It will be a 1 or a 0 for every underlying row within the current rowGroup. I have tried to use the First(,) function in a Column Visibility expression on the "Invoice Value" Column. However, I get the following error whenever I try to limit the scope of the First Function to the current Payslip Rowgroup using the RowGroup name.
"The Hidden expression for the tablix 'X' has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset. "
So, my Question(s)
Can you define a RowGroup name as the Scope argument in a First() function?
If not, What's the best way of achieving this without completely re-working my Dataset / RDL to accomplish this. (Using SSRS2008)
Why is it always just after posting a forum question, you figure it (or some workaround) out?
I'd still like some (better) answers if anyone sees this, but I've set a cell in the tablix to the value of the bit field that determines whether to show the column or not. I then changed my Column Visibility expression to check the cell value (using ReportItems!textboxname.Value) and it's working. as I scroll the payslips the columns visibility changes appropriately.