SSRS expression IIF() and sum - reporting-services

I have this error message that pops up when trying to run a report. It is a SSRS Report for Dynamics AX 2012.
System.Web.Services.Protocols.SoapException: The Visibility.Hidden expression for the text box ‘Textbox183’ 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.
at Microsoft.ReportingServices.Library.ReportingService2005Impl.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Guid batchId, Warning[]& Warnings)
at Microsoft.ReportingServices.WebServer.ReportingService2005.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)*
This expression below is set on a textbox's visibility.
Format(sum(IIF(Fields!InventOnHand.Value <= Parameters!CutOff.Value, Sum(Fields!InventOnHand.Vallue), 0 )), "#, ##0.00")
Please help me understand why that error above shows and how to fix this expression.

When do you want to see your text box? Your expression is calculating a dollar amount and not resulting in a True/False condition need for Visibility.
Since the error is asking about your dataset, I assume it's not in a table - a text box in a table wouldn't need a dataset sine the table is associated with a dataset.
Assuming that you only want to see the text box when the SUM of Inventory is greater than the CutOff parameter, you'd want:
=IIF(SUM(Fields!InventOnHand.Value, "Dataset1") <= Parameters!CutOff.Value, True, False)

Related

SSRS Manually select values passed to a multi-value subreport parameter

In SSRS, I have a summary report, and when I click on any figures, it drills through a subreport that generate a list of skus.
I have setup the cells in the summary report and selected all Parameter for the drill through report.
For a multi-value parameter in the subreport, I want to manually select 2 out of 3 available values.
In the textbox property, under Action and parameters, What is the expression to specify the values I want to pass to my subreport?
1,2 - If your parameter is a integer. Don't use the expression with an equals sign, just 1,2 in the parameter value.
If your parameter is a string, I believe you need to double the double quotes.
""1"",""2""
You could also use the SPLIT function to create a string array from the hard-coded values:
=Split("1,2", ",")
Neither formula worked, but at the end, I just modified the list of available value on the subreport and added another value. Then, in the dataset query, I adjusted the WHERE clause so that when the paramater has said value, the field IN ("1","2")

SSRS - Calculating percentage based on calculated field

When I tried this
=Count(Fields!Refcode.Value) / Sum(count(Fields!Refcode.Value), "Branch")*100
This was the response I got
The Value expression for the text box ‘Textbox130’ 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.

Setvalue Display the first value that is not Zero

I use microsoft sql server report builder.
I have a big sql query for the Presentation of my Report. i want to assign the output of one of the Columns to a textbox. the txbox should be displayed the first value of the table which is not zero.
I tried that First(Fields!name.Value, "V_Tabelle") .but if the first value is null, the textbox remains empty
I tried that IIf(IsNothing(Fields!name.Value), "null", Fields!name.Value) , but i am receiving an error. field references outside a data area must be included in aggregate functions that specify a dataset area.
First(Fields!name.Value, "V_Tabelle")
IIf(IsNothing(Fields!name.Value), "null", Fields!name.Value)
The value expression for the text field "Status6" refers directly to the field "name" without specifying a dataset aggregate. If the report contains multiple datasets, field references outside a data area must be included in aggregate functions that specify a dataset area.
This way it checks if the first value is null, is this the case the text Empty will be displayed.
=IIF(First(Fields!YourField.Value, "DataSet1") = Nothing,
"Empty",
First(Fields!YourField.Value, "DataSet1")
)

Combine two datasets in SSRS Reporting Services and count

I have two datasets - In dataset 1 MedAdministration I have Medical_Condition. In dataset 2 ProblemList I have Medical_Condition. I want to combine both datasets and count.
For instance Heart attack may be in dataset 1 and in dataset 2. I just want the report to show Heart Attack 20 which would be a combination of both datasets and the total from both into one total on the report.
I have tried the lookup function and the join, but I keep getting errors.
=Lookup(Fields!Medical_Condition.Value,Fields!Medical_Condition.Value, "ProblemList")
"System.Web.Services.Protocols.SoapException: The Value expression for
the textrun ‘Medical_Condition.Paragraphs[0].TextRuns[0]’ has an
incorrect number of parameters for the function ‘Lookup’. at
Microsoft.ReportingServices.Library.ReportingService2005Impl.SetReportDefinition(String
Report, Byte[] Definition, Guid batchId, Warning[]& Warnings) at
Microsoft.ReportingServices.Library.ReportingService2005Impl.SetReportDefinition(String
Report, Byte[] Definition, Warning[]& Warnings) at
Microsoft.ReportingServices.Library.ReportingService2010Impl.SetItemDefinition(String
ItemPath, Byte[] Definition, String expectedItemTypeName, Property[]
Properties, Warning[]& Warnings) at
Microsoft.ReportingServices.WebServer.ReportingService2010.SetItemDefinition(String
ItemPath, Byte[] Definition, Property[] Properties, Warning[]&
Warnings)
I can't even get it to combine the data, let alone count it. What am I doing wrong?
Thanks in advance!
Tara
Lookup function takes 4 parameters:
Lookup(source_expression, destination_expression, result_expression, dataset)
To expand on SuperSimmer's answer, you'll need to use the correct lookup parameters within your expression to add the two. I don't know for sure how the report is laid out, but for example, if you need values summed for Heart Attack, you'll need a count of that field from each dataset and add those together.
=Count(IIF(Lookup(Fields!Medical_Condition.Value,Fields!Medical_Condition.Value, Fields!Medical_Condition.Value, "ProblemList") = "Heart Attack", 1, Nothing))
+ Count(IIF(Lookup(Fields!Medical_Condition.Value,Fields!Medical_Condition.Value, Fields!Medical_Condition.Value, "MedAdministration") = "Heart Attack", 1, Nothing))
If you'd prefer a dynamic result or if the 'Condition' is provided from a parameter, you'd replace the "Heart Attack" with Parameters!Condition.Value to check each dataset for the value provided.

Lookup function error in SSRS 2014

When i am creating SSRS report getting error like" the value expression for the text box "" has a scope parameter that is not valid a lookup function."
It seems that you have a LOOKUP function in an expression that is using an incorrect value for the dataset score.
In this example, Product" is the scope.
=Lookup(Fields!SaleProdId.Value, Fields!ProductID.Value, Fields!Name.Value, "Product")
Since it doesn't give the text box name, the expression with the Lookup must be in some other object.