2017-08-30 40 views
0

我使用SSRS 2008年建立的報告如何使用在SSRS 2個數據集進行比較,並顯示結果

功能:其爲具有2個集

1) dslocation 
2) prevdslocation 

There are few fields like say: 

    1) locationId 
    2) locationName 
    3) mmpremium 
    4) sspremium 

我已創建報告

在我的報告中,我需要顯示如下結果:

Locationname  mmpremium(dslocation) - mmpremium (prevdslocation) 

SANDY    1000 - 2000 
RANSY    2000 - 3000 

我想在r eport級別而不是SQL返回爲單個數據集。

+0

我不認爲這是可能的。只要您可以確定表格將按照相同的順序排列,您就可以將許多表格放在一起。這會在外觀上進行物理連接。我可以問爲什麼你不想加入SQL來返回一個數據集? – Schmocken

回答

0

如果可能的話,做SQL這種東西它使得像容易得多......

但是,您可以使用查詢來實現這一目標,如果它是兩個數據集之間簡單的「加入」。

創建基於您的第一個數據集(dsLocation)表,然後添加一個額外的列,並設置表達這樣的事情...

=Lookup(Fields!LocationID.Value, Fields!LocationID.Value, Fields!mmPremium.Value, "prevDsLocation") 

這將着眼於locationid該行,試圖找到在prevDsLocation的LocationID中匹配,如果找到匹配,它將從prevDsLocation返回mmPremium。

0
Following are the tables and data used for report creation- 
create table dslocation 
(
locationId int 
, locationName varchar(20) 
    , mmpremium int 
    , sspremium int 
) 
INSERT INTO dslocation 
VALues (1, 'SANDY', 1000,'') 
,(2, 'RANSY', 2000,'') 

create table prevdslocation 
(
plocationId int 
, plocationName varchar(20) 
    , pmmpremium int 
    , psspremium int 
) 

INSERT INTO prevdslocation 
VALues (1, 'SANDY', 2000,'') 
,(2, 'RANSY', 3000,'') 

Then add a column and write following expression in placeholder- 
=Fields!mmpremium.Value-join(LookupSet(Fields!locationId.Value,Fields!plocationId.Value,Fields!pmmpremium.Value,"prevdslocation"),",") 

Following is the screenshot of the solution - 
[![enter image description here][1]][1] 



    [1]: https://i.stack.imgur.com/mdKML.jpg 
相關問題