SSRS Expression: The value expression for textbox has scope parameter that is invalid for aggregate

Sometimes this error occurs while we use different DatasetName in Experssion.

Like in my case I have solved this error by doing below thing,

Before it was like below,

="For Man " + 
   IIF(Len(First(Fields!Lname.Value, "DataSet1")) > 0,
   First(Fields!Lname.Value, "DataSet1"),"") & IIF(Len(First(Fields!Fname.Value, "DataSet1")) > 0,
   ", " + First(Fields!Fname.Value, "DataSet1"),"")

After changed it to below it is working fine now,

="For Man " + 
    IIF(Len(First(Fields!Lname.Value, "LastChangedDataSetName")) > 0,
    First(Fields!Lname.Value, "LastChangedDataSetName"),"") & IIF(Len(First(Fields!Fname.Value, "LastChangedDataSetName")) > 0,
    ", " + First(Fields!Fname.Value, "LastChangedDataSetName"),"")

Note: So here the mistake was I have changed the DataSet Name From DataSet1 to LastChangedDataSetName and remained to change that name in last Expression that I have already written before changing DataSet Name.


I don't know what is wrong, but have created a similar report that works. Create a new blank report, then create a dataset (from SQL Server) with following query:

SELECT 'ACME' AS firmanaam, 10000 AS indienstfirmanr, 'Doe' AS naam, 'Jon' AS voornaam, 987654 AS personeelsnr

DataSet image

Then add your parameter

Parameter Definition

Add a textbox to the report, with code:

= Iif(Parameters!ReportParameterPersoneelsNr.Value.Equals(String.Empty), "Prestaties " & First(Fields!firmanaam.Value, "DataSetHrm") & "(" & First(Fields!indienstfirmanr.Value, "DataSetHrm") & ")", "Prestaties " & First(Fields!naam.Value, "DataSetHrm") & " " & First(Fields!voornaam.Value, "DataSetHrm") & "(" & First(Fields!personeelsnr.Value, "DataSetHrm") & ")")

Then run the report with or without a value for the parameter:

Preview of Report

Preview with empty param


I faced a similar issue recently in one of my reports. The reason I have this error is that the name of the data set and the expression in the report do not match.

I have a date field which is populated with User preferences and the expression is First(Fields!column.Value, "datasetname"). The dataset name and the dataset name specified in reports data should match.