Monday, March 19, 2012

Differentiate between fields of TWO Datasets in a single report

Dear ppl,

I have got 2 datasets D1 & D2 in a Report. How can i differentiate between the fields of these two.

e.g. I got Name field in both the datasets. So when i do =Fields!Name.Value in a textbox the report gives me error

How can i tell the report from which dataset to pick up the field ?

Regards

Nabeel

Is your textbox inside a Data Region (List, or Table), Or is it placed independently on the form?If is placed independently on the form you would have to reference it using an aggregate expression, using the following format.

=First(Fields!Name.Value, “Scope”)

Scope being then name of the Dataset.

Hope this helps!!!

Roberto Hernández-Pou
http://community.rhphconsulting.net

|||

Normally the text box will be nested in a list control which has a dataset property (when dataset has multiple rows).

Alterantively if you just put the textbox directly into the body of the report, you can use an aggregation function which takes the dataset name as the second parameter e.g.

=First(Fields!Name.Value, "DataSetName")

|||

Hello Nabeel,

Try the following syntax: =(Fields!Name.Value, "Put the name of your dataset here including the quotes")

Regards,
Worf|||

cheers guys..thanx for the help

||| why the aggregate function is required for the differentiation. cant it just differentiate with the name?|||

It's all to do with context.

Usually, you have an expression such as =Fields!x.Value or =Sum(Fields!x.Value) in a textbox of a matrix, table, or list. Each of these controls needs a dataset property to be specified. This sets the context and hence the dataset from which the field is sourced. This can be overridden within an aggregate function by explicitly specifying the scope of the aggregate. This can either be the name of a group (within the current table or matrix) or an entirely separate dataset.

So in answer to your queation, an aggregate function is not in fact required just to specify the dataset. The dataset is normally inherited from a parent control. If no aggregate function is specified for a cell that is aggregated (groupped) then the First function is applied by default.

No comments:

Post a Comment