-2

I saw the post on WHERE clause in SSRS expression. I am also trying to do a where clause, but in a different way. I need to show ItemDesc when ItemId = 4. I set a parameter so that it will always equal 4 for this cell. Now I just need the matching description field. I cannot hard code it because the description may change one day. Is there a way to associate the two fields?

=IIF(Parameters!ItemID_4.Value = 4, Fields!ItemDesc.Value,"")

I am converting from Crystal Reports to SSRS. This first image is the output from CR. I only need to show that ItemDesc in that top left cell.

enter image description here

This next image is from SSRS. It is not limiting the descriptions. It seems to be doing what my expression is saying. ItemID = 4, so display all ItemDesc values but the two fields are not associated right now. I need it to only show the matching value.

enter image description here

Thank you for your help.

user3691608
  • 47
  • 12
  • Its not clear what you are asking. The expression you posted will do what you say you want to do? What exactly is the problem? Show sample data and expected outcome,plus what you have so far and people will be able to help you. – Alan Schofield Feb 20 '20 at 21:27
  • If you want to filter for the ItemID of 4, add a WHERE clause to the SQL like `WHERE ItemID = @ItemID`. Then map that parameter to the SSRS parameter in the Parameters tab of the Dataset Properties. Then when you select 4 in your parameter, only the ItemID of 4 will be shown. – Hannover Fist Feb 20 '20 at 22:31

1 Answers1

0

I cannot hard code it because the description may change one day.

You are hard coding the parameter anyway by trying to do it that way. I don't think you need a parameter to achieve the result unless you are restricted from adjusting the dataset query.

If you are using an embedded SQL query for your dataset, I would just put a filter in WHERE clause: WHERE ItemID = 4

Another way if you can't adjust the query is to go to Report Data view > Right click on the dataset for your table, "Dataset Properties" > go to the "Filters" tab and add a filter with these settings: Expression = ItemID, Operator = "=", Value = "4" (or "@ItemID" if you want to keep your parameter).

papermoon88
  • 456
  • 2
  • 8