Concatenating/Merging 2 DataSets with exact same columns [duplicate]

為{幸葍}努か 提交于 2019-12-13 06:12:54

问题


I'm trying to figure out if there is any way in Report Builder 3.0 to concatenate or merge 2 different "DataSet" objects which both have exactly the same column names into one set of data, for the purposes of displaying in a pie chart.

My SQL query looks similar to this for both data sets:

DECLARE @DateCreatedStart date = GETDATE()-14
DECLARE @DateCreatedEnd date = GETDATE()

SELECT i.Source, COUNT(*) AS Count_of_Source
FROM [DBName].[dbo].[Items] i
WHERE (i.DateCreated BETWEEN @DateCreatedStart AND @DateCreatedEnd)
GROUP BY i.Source

So I end up with 2 data sets which both have Source and Count_of_Source columns.

Edit: I've found out that I can't use the Lookup function how I thought I might be able to. It just looks in one dataset and finds a match in another dataset, and pulls a value from the same row in a similar manner to Excel's vlookup/hlookup.

Edit more info: I found this answer https://stackoverflow.com/a/24312870/1804496 that showed me I could use a scope parameter on my expression to specify the name of my second data set. I added a second values member that uses an expression =SUM(Fields!Count_of_Source.Value, "DataSet2"), but the chart looks completely wrong and I don't know how to fix it at the moment. It looks like the single row from my second data set is being repeated n times, where n is equal to the number of unique Source values from my first data set. No idea what is going on there.


回答1:


The best way to combine the datasets is using the SQL Server. So you can just add a new dataset and paste in the two queries with a UNION ALL between them.



来源:https://stackoverflow.com/questions/36894820/concatenating-merging-2-datasets-with-exact-same-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!