简体   繁体   中英

Filter data on Tablix based on value from another Dataset in Report Server

In my Report I have two DataSets. One of them returns Car Names, and another one returns Car infos.

So, for illustration as the real data is a bit more complicated, First Data set has

[Car Name] [Row]
Honda       1
Toyota      2
BMW         3

Second Data set is

[Car Name] [Color] [Weight]
Honda      Blue    1500kg
Toyota     Red     1650kg

I need to mention that both DataSets are dynamic, meaning they will have different outputs in all columns. The final result that I'm looking for is like this

[Car Name]

[Color]
[Weight]
...

This data will be contained within several rectangles that are going to be dynamically created. The [Car Name] column in the final result is dynamic and is connected to the [Row] column in the First Data Set. So, for example, the value of the first rectangle that gets data from DataSet1 has the expression

=First(IIf(Fields!Row.Value = 1, Fields!CarName.Value, 0),"DataSet1")

Since this data is Dynamic, I need the below data for [Color] and [Weight] to be shown only for that [Car Name] which is dynamic from DataSet1. How can I filter the DataSet2 to only show that dynamically set [Car Name]? I tried using Filters in Tablix, but I can't use ReportItems!TextBoxXX.Value for example.

I can't solve this on SQL level.

The following expression gives you for the same car names in both datasets the color from the second dataset. I am not sure what you want to do but this might help you:

'For the car color
=Lookup(Fields!CarNameDataset1.Value, Fields!CarNameDataset2.Value, Fields!CarColorDataset2.Value, "Dataset2")

You can put this into a filter expression as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM