问题
It is basically the same question I had in this thread: Adding values to a Report when there is no Data in query SSRS
The only difference now is that I want to extend the same functionality to different Datasets.
Imagine this:
I have two Datasets. Dataset1
, Dataset2
.
Both have the same primary key, in this case: Sales Rep Category
Now in Dataset1 I have the following Data:
The idea in that thread was to put "0"
Each time a Sales Representative Did not have all the categories, if you see for example Sales Rep on DataSet1
, does not have G1,G2
Category so In those cases they have to put 0.
Thanks by the answer of the community this can be achieved by adding a Calculated Field on DataSet1:
=Fields!SalesRep.Value & "-" & Fields!Category.Value
So that will give you for example 11-G1
for the 1st Row. and the expression for each Row (For each category) will be:
=iif(IsNothing(lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7")),0,
lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7"))
As you can see, the ReportItems!Textbox62.Value
saves the value of the Category so If 11-G1 is nothing (dont exist) put "0"
.
The idea here is to do the same thing with DataSet2
.
The tricky part is that we have to ask if 11-G1
equals 14-G1
because in DataSet2
the SalesRep
does not exist for all the categories it must put "0"
. Both are grouped as SalesRep
.
来源:https://stackoverflow.com/questions/33348130/adding-values-to-a-report-when-there-is-no-data-in-query-ssrs-between-datasets