SSRS report - LookupSet

mark goldin 691 Reputation points
2021-07-22T09:53:30.83+00:00

I am trying to use the following function to get values from a dataset where a value is equal zero, just to test if I can get lookup working:
LookupSet(0, Fields!CurrentState.Value, Fields!CurrentState.Value, "Dataset")

I am getting:
Fields cannot be used in query parameter expressions.

Please help.

Thanks

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,925 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Joyzhao-MSFT 15,586 Reputation points
    2021-07-23T02:07:29.947+00:00

    Hi @mark goldin ,
    Please make sure your expression is correct. There seems to be an error in the Lookupset Function you are using.

    LookupSet(source_expression, destination_expression, result_expression, dataset)  
    

    for example:
    In the following expression, LookupSet compares the value TerritoryGroupID to ID for each row in the dataset called "Stores". For each match, the value of the StoreName field for that row is added to the result set.

    =LookupSet(Fields!TerritoryGroupID.Value, Fields!ID.Value, Fields!StoreName.Value, "Stores")  
    

    For the usage and precautions of Lookupset, please refer to: Report Builder Functions-LookupSet Function.

    If you just want to use the Lookupset function to test the "Field cannot be used in the query parameter expression" error, and you are having trouble creating parameters, I suggest you check the following links first:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/70acba36-4598-4cb6-826c-3810f79c2448/problem-with-fields-in-parameter-expression?forum=sqlreportingservices
    https://stackoverflow.com/questions/13580190/fields-cannot-be-used-in-report-parameter-expression

    If it is not the above situation, please describe in detail what you did before the error was reported for the first time.

    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. mark goldin 691 Reputation points
    2021-07-23T10:24:50.46+00:00

    So, that function only can be run from within a data region. Is that correct?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.