SSRS - Expression using different dataset fields

73,643

You can achieve that by specifying the scope of you fields like this:

=First(Fields!fieldName_A.Value, "Dataset1") / First(Fields!fieldName_B.Value, "Dataset2")

Assuming A is 10 and B is 2 and they are of type numeric then you will have the result of 5 when the report renders.

When you are in the expression builder you can choose the Category: Datasets, your desired dataset highlighted under Item: and then double click the desired field under Value: and it will appear in your expression string with the scope added.

Using same logic you can concatenate two fields like so:

=First(Fields!fieldName_A.Value, "Dataset1") & “ “ & First(Fields!fieldName_B.Value, "Dataset2")
Share:
73,643
Zolt
Author by

Zolt

Updated on July 01, 2020

Comments

  • Zolt
    Zolt almost 4 years

    I have a report with multiple data-sets. Different fields from different data-sets are used in different locations of the report.

    In one part of the report, I need to do a calculation using fields from two different data-sets. Is this possible within an expression?
    Can I somehow reference the data-set the field is in, in the expression?

    For example, I'd like to do something like this:

    =Fields.Dataset1.Field / Fields.Dataset2.Field
    
  • Zolt
    Zolt about 12 years
    Thank you. This is exactly what I needed.