SSRS; How to Merge Two Matrices Together


In SSRS 2008 R2, I have two separate but very similar matrices.  Each is based on a separate dataset, and each dataset pulls from a separate SQL database.

Each matrix has two columns--Vendor ID and Monthly Purchases.

I want to join these two matrices into one.  But, what if the same vendor is in each matrix?  How do I join these two objects where vendors, as well as their Monthly Purchases amounts are combined (summed) seamlessly?

And, I'm going to have detail "drill-down" data for each matrix.  If I combine them, will those drill-downs still work?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ValentinoVBI ConsultantCommented:
As far as SSRS is concerned, you can't do that.  It's impossible to combine data from two datasets in the same data region (tablix).  Except when you'd use the lookup functions but it would be a tough job to achieve your combined sums.

So this means you'll have to handle it on the query side.  Are those two databases located on the same SQL Server database engine instance?  If yes, then you can reference the database name in the FROM clause:

SELECT <fields>
FROM DB1.Schema.Table
SELECT <fields>
FROM DB2.Schema.Table

Open in new window

Of course this implies that your databases have the same name on each environment (DEV/UAT/PRD).  To avoid issues with that you could consider using synonyms, possibly in combination with a linked server if you're dealing with two different instances.

In any case, if you can build a query that combines the data from both your tables, you'll be able to achieve your report requirement.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.