reporting-servicesexpressionssrs-2008ssrs-expression

How can I get From a SSRS DataSet Row the Value Where Condition is True


I have a DataSet called Reporting that include TagName, Value and DateTime.

Now my question: In my SSRS Report I have a TextBox where I want the Value of a TagName.

For Example: I have TagName called: "TT101" with the Value 21.

So my TextBox should show 21.

I have tried with this expression:

=IIf(Fields!TagName.Value = "TT101" , Fields!Value.Value ,0)

So I expected the output this expression to be 21 but it was 0 because it's always false or Null and I can't find out why?


Solution

  • enter image description here So as described, You had data coming from Dataset something like below. As you already have attribute (column) which gives you value why do you need any expression for it.

    In SSRs just use Table and assign Field to a column it will automtatically populate N number of rows (For ex.100 rows if your Dataset returns 100 rows) Here is the link for Tablix in SSRS https://learn.microsoft.com/en-us/sql/reporting-services/report-design/tables-report-builder-and-ssrs?view=sql-server-2017

    As per your comment, you need max only where TagName is TT101. Let's do something like below.

    Create a new Column let's call it "Value for Tag TT101" Now for this column set Value with condition as

    IIf(Fields!TagName.Value = "TT101" , Fields!Value.Value ,0)
    

    What this will do, will set Value for TT101 or 0 if different Tag Name.

    Now you can have expression for Textbox as below

    =Max(Fields!newColumValue.Value, "myDataSetName")
    

    This shall work for you.